1022: [shoi2008] John's game Time Limit: 1 secMemory limit: 162 MB
Submit: 1189Solved: 734
[Submit] [Status] Description
John often plays a very interesting game with his brother: There are n piles of stones on the table. John and his brother take turns to take stones, you can select a pile of stones at will, and take away any number of stones in the pile, but not one stone or not. We stipulate that the person who gets the last one will lose. John is very stubborn. He insisted that the first person has a great advantage, so he always takes the first stone, and his brother is more intelligent, he has never made any mistakes in the game. John asked you to be his adviser before getting angry. Naturally, you should first write a program to predict who will win the game.
Input
The input in this question is composed of multiple groups of data. The first row contains an integer T, indicating that the input has a total of T groups of data (T ≤ 500 ). The first row of each group of data contains an integer n (n ≤ 50), indicating a total of N stones. Next there are n integers not greater than 5000, the number of stones in each heap.
Output
The output of each group of data occupies one row, and each row outputs one word. If John can win the game, "John" is output; otherwise, "brother" is output. Note the case sensitivity of words. 2 3 3 5 1 1 1
Sample Input John
Brother
[Data scale]
For 40% of data, T ≤ 250.
For 100% of data, T ≤ 500.
Sample output hintsource
Anti_nim games: the first player wins only when
1) All sg XOR! = 0 and a SG> 1
2) All sg XOR = 0 and No SG> 1
Do not understand the proof. Make up later.