#P1290. 欧几里德的游戏

欧几里德的游戏

Description

Two descendants of Euclid, Stan and Ollie, are playing a number game invented by their ancestor. Given two positive integers MM and NN, 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 00. 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 00; that player wins. The play sequence for the numbers (25,7)(25, 7) is as follows:

  • Start: (25,7)(25, 7).
  • Stan: (11,7)(11, 7).
  • Ollie: (4,7)(4, 7).
  • Stan: (4,3)(4, 3).
  • Ollie: (1,3)(1, 3).
  • Stan: (1,0)(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 CC.
Each of the next CC lines contains one test case with two positive integers M,N(M,N<231)M,N(M,N<2^{31}).

Output Format

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

2
25 7
24 15

Stan wins
Ollie wins

Hint

1C61 \leq C \leq 6.

Translated by ChatGPT 5