#P4101. [HEOI2014] 人人尽说江南好
[HEOI2014] 人人尽说江南好
Description
Xiao Z is a hardcore ZRP (Zealot Round-game Player), and he recently recalled a game he played in Jiangnan when he was a child.
In the past, people would compose lyrics while playing games. For example, this piece “Pusaman (Púsà Mán)” was written by Wei Zhuang while playing: 人 人 尽 说 江 南 好, 游 人 只 合 江 南 老。
However, today we are not very concerned about what people wrote. We only care about the game that Xiao Z played. The rules are as follows: there are piles of stones, each initially having stone. Xiao Z and his friend take turns, and Xiao Z moves first. A move can merge any two piles into one pile. Whoever cannot move loses.
However, if a pile becomes too high, it might be dangerous. Therefore, they agreed that at any time, the number of stones in any pile cannot exceed . That is, if there are two piles with and stones and , then these two piles cannot be merged.
Xiao Z and his friend are very smart, so they always choose optimal strategies. Now Xiao Z wants to know, given and , who will win.
Input Format
This problem contains multiple test cases. The first line contains a single integer , the number of test cases.
Each of the following lines contains two positive integers .
Output Format
Output lines, each being or . If it is , it means Xiao Z (the first player) will win. If it is , it means the second player will win.
5
7 3
1 5
4 3
6 1
2 2
1
1
1
1
0
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , .
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号