Submit | All submissions | Best solutions | Back to list |
IBIGAME - A New Task for Ibrahim |
One day Rashad and Mahmud were talking about Nim and other mathematical games while teaching game theory to their students. Ibrahim, as usual, solved all problems after the lecture, so teachers decided to give a hard task to him:
Ziya the ProGamer (yes, you know him from my this problem) and Rafael a.k.a. Farael are playing a game with two piles that have A coins in first one, and B coins in the latter. Of course, Ziya starts first and they take alternating turns making the following moves: The player whose turn is; picks one pile with at least two coins, removes from that pile x coins for some 2 ≤ x ≤ 4, and adds one coin to another pile. Players can choose different x in each move, and who cannot make move loses. As you know, Ziya is ProGamer (don't confuse with Programmer!!), and Rafael is Farael (that special name helps him to make the best move possible!!) they both play perfectly.
Ibrahim thought about a dynamic programming solution for this task but the constraints for the task baffled him. The only idea in his mind is observing the answer, however, he thinks that his solution is not enough for this task, so your help is needed here. Please, answer some queries that Ibrahim wants to know.
Input
The first line of the input consisting of the number of the queries Ibrahim will ask - T (1 ≤ T ≤ 5000). For each query, there are given two numbers, A and B (1 ≤ A, B ≤ 1018; a little long game, huh?) in a separate line.
Output
For each query of Ibrahim, print "Ziya" if Ziya will win the game, "Farael" otherwise, in separate line.
Example
Input:
3 1 5 2 3 4 12
Output:
Ziya Farael FaraelNote: Please, read the statement again (23.06.2018).
Added by: | Barish |
Date: | 2018-06-11 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Deep places of my brain |
hide comments