P1290 Euclid's Game

Description

Two descendants of Euclid, Stan and Ollie, are playing a number game invented by their ancestor. Given two positive integers $M$ and $N$, starting with Stan, on each turn the player subtracts a positive multiple of the smaller number from the larger number, and the result must not be less than $0$. Then it is Ollie’s turn, using the new pair formed by the result and the other number, and the same operation is repeated. The process continues until someone makes the larger number become $0$; that player wins. The play sequence for the numbers $(25, 7)$ is as follows: - Start: $(25, 7)$. - Stan: $(11, 7)$. - Ollie: $(4, 7)$. - Stan: $(4, 3)$. - Ollie: $(1, 3)$. - Stan: $(1, 0)$. Stan wins the game. Now, assuming both players play optimally, who will win?

Input Format

**This problem contains multiple test cases.** The first line contains the number of test cases $C$. Each of the next $C$ lines contains one test case with two positive integers $M,N(M,N

Output Format

For each test case, output one line. If Stan wins, output `Stan wins`; otherwise output `Ollie wins`.

Explanation/Hint

$1 \leq C \leq 6$. Translated by ChatGPT 5