#C11788. Determine the Winner
Determine the Winner
Determine the Winner
Tom and Jerry are engaged in a strategic game involving piles of stones. The game is played as follows:
- There are n piles of stones, and each pile contains a certain number of stones.
- Tom always makes the first move, and then Tom and Jerry alternate turns.
- On each turn, a player must remove exactly one entire pile.
- The game ends when there are no piles left; the player who cannot make a move loses.
Both players play optimally. It turns out that the outcome depends solely on the parity (odd or even) of the number of piles. If n is odd, Tom wins; if n is even, Jerry wins.
Your task is to implement a program that reads multiple test cases from standard input and determines the winner for each test case.
Note: The number of stones in each pile does not affect the outcome.
inputFormat
The input is read from stdin
and has the following format:
T n_1 a_11 a_12 ... a_1n n_2 a_21 a_22 ... a_2n ... n_T a_T1 a_T2 ... a_Tn
Where:
- T is the number of test cases.
- For each test case, the first line contains an integer n, the number of piles.
- The next line contains n space-separated integers representing the number of stones in each pile.
outputFormat
For each test case, output the winner's name (Tom
or Jerry
) on a separate line. The output should be written to stdout
.
2
3
4 2 1
2
1 1
Tom
Jerry
</p>