문제
Farmer John and his archnemesis Farmer Nhoj are playing a game in a circular barn. There are () rooms in the barn, and the th room initially contains cows (). The game is played as follows:
Both farmers will always be in the same room. After entering a room, each farmer takes exactly one turn, with Farmer John going first. Both farmers initially enter room .If there are zero cows in the current room, then the farmer to go loses. Otherwise, the farmer to go chooses an integer , where must either be or a prime number at most the number of cows in the current room, and removes cows from the current room.After both farmers have taken turns, both farmers move to the next room in the circular barn. That is, if the farmers are in room , then they move to room , unless they are in room , in which case they move to room .
Determine the farmer that wins the game if both farmers play optimally.
입력
The input contains test cases. The first line contains (). Each of the test cases follow.
Each test case starts with a line containing , followed by a line containing .
It is guaranteed that the sum of all is at most .
출력
For each test case, output the farmer that wins the game, either "Farmer John" or "Farmer Nhoj."
예제 입력 1
5
1
4
1
9
2
2 3
2
7 10
3
4 9 4
예제 출력 1
Farmer Nhoj
Farmer John
Farmer John
Farmer John
Farmer Nhoj
점수
Inputs 2-4 satisfy .Inputs 1, 2, and 5-7 satisfy .Inputs 8-20 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인