Game
Time limit2sMemory limit256 MB
If the start is within Manhattan distance m of the finish, First wins on move 1; otherwise both players can avoid losing forever, so the result is Infinity.
- Level
Easy3 of 10
- Topics
- Game theory, Math, Implementation
- Solved
- No attempts yet
Problem
Jury members of Russian Code Cup sometimes play various games in their free time.
For example, between the last two rounds, the jury came up with a new game with the following rules:
- Initially, a piece is at point on an infinite field.
- In one move, a player can move the piece from to any cell such that .
- Two players play the game, taking turns.
- The player who places the piece on wins.
You are given descriptions of games. Each description has five numbers: the move limit , and the starting and final positions of the piece.
For each game, determine who wins under optimal play and on which move. Neither player wants to lose, so the players may play indefinitely.
Input
The first line contains one integer (), the number of games. The next lines each contain five integers , , , , (all numbers are in the range from 1 to 1000), the move limit and the starting and final coordinates of the piece. The starting and final points are always different.
Output
For each game, print one line. Print "First" if the first player wins, "Second" if the second player wins, and "Infinity" if the players play indefinitely. If the game is finite, also print the number of the move after which the game ends, separated from the result by a space.