1022: [SHOI2008] Little John's game John

Source: Internet
Author: User

1022: [SHOI2008] Little John's game John Time limit:1 Sec Memory limit:162 MB
submit:1322 solved:829
[Submit] [Status] Description

Little John often plays a very interesting game with his elder brother: there are n heaps of stones on the table, and Little John and his brother take the stones in turn, and when everyone takes it, they can choose a heap of stones at random, take away any number of stones in this heap of stones, but not a stone nor take it, we stipulate that the person who takes the last Little John is very stubborn, he insists that the first person has a great advantage, so he always take the stone first, and his brother is much smarter, he has never made mistakes in the game. John asked you to be his adviser before he was angry. Naturally, you should first write a program that predicts who will win the game.

Input

The input of the subject consists of multiple sets of data, and the first line consists of an integer t, which indicates that the input has a total of T-group data (t≤500). The first row of each set of data consists of an integer n (n≤50), which represents a total of n heap stones, followed by N of an integer not exceeding 5000, representing the number of stones per heap.

Output

The output of each group of data takes one row, and each line outputs a word. If John can win the game, output "John", otherwise output "Brother", please note the word case.

Sample Input2
3
3 5 1
1
1Sample OutputJohn
BrotherHINT

"Data Size"

For 40% of data, t≤250.

For 100% of data, t≤500.

Source

Seerc2007

Puzzle: The game theory of Meng Meng ... Do you feel like you're back in your childhood?
1 var2 I,j,k,l,m,n,x:longint;3 begin4 Readln (m);5       fori:=1  toM Do6          begin7 READLN (n);8k:=0; l:=0;9                forj:=1  toN DoTen                   begin One read (x); A                        ifX>1  ThenInc (k); -l:=l XOR x; -                   End; the               if(l=0) XOR (k=0) ThenWriteln ('Brother')ElseWriteln ('John'); -          End; - End.

1022: [SHOI2008] Little John's game John

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.