All submissions for this problem are available.
Tom and Jerry are very good friends. They like to play several games. Today they are playing filling the jars, which is described as below.
There are n jars of sizes N1, N2, N3, ... and Nn. The maximum number of cashews a jar can contain is equal to the size of the jar.
Each player on his turn can put x number of cashews (where x is a perfect square and x< 100) to any of the jar. The player who is unable to put cashews will lose.
As Tom is stronger than Jerry, he will always start the game.
You have to tell, who wins the game, if they both play optimally.
Note: The total number of cashews is equal to the sum of the sizes of the jars.
First line contains T, the number of test cases.
The first line of each test case contains n, the number of jars.
The second line of a test case contains n space separated integers, denoting the sizes of the jars.
For each test case, print in a new line who will win the game "Tom" or "Jerry" (quotes for clarity).
- 1 ≤ T ≤ 100
- 1 ≤ n ≤ 1000
- 1 ≤ N1, N2, N3, ...,Nn ≤ 100000
Input: 1 2 4 5 Output: Tom
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.