Starting from:

$20

Algothon- Tom and Jerry 9 Solved

Tom and jerry are are playing a game with N candies. Tom always takes candies first, and the then two (tom and jerry) move in alternating turns. There are some rules as well,

Ina single move, one can get either 2,3 or 5 candies
If one can't take any candies he looses the game
Given an amount of candies, find and print the name of the winner. Remember that tom and jerry are equally intelligent and play optimally.

Example 1

If there are 4 candies first way

Tom takes 3 candies
Then there are only 1 candy
Jerry can't take any according to rules (one can take only or 5)
Tom wins second way
Tom takes 2 candies
Then there are 2 candies left
Jerry takes those 2 candies
No candies left for Tom
Tom wins since tom always takes cadies first he can select the first way and win
Answer - Tom

Input Format

Integer(Candies amount)

Constraints

Output Format

Print the name of the winner. Tom or Jerry

Sample Input O

Sample Output O

More products