Turjo and Urjo are two exceptionally good brothers. One lazy Friday afternoon, the power went out, leaving them completely bored with nothing to do. To pass the time, Urjo decided to invent a math game to challenge Turjo's calculating speed.
Urjo grabs a piece of paper and writes down two starting numbers, $$$A$$$ and $$$B$$$. He then tells Turjo that he is generating a special sequence. However, since standard addition is way too easy for them, Urjo uses the Bitwise XOR operator ($$$\oplus$$$) to generate the next terms.
Let $$$F$$$ be a sequence. The sequence is defined by Urjo as follows:
$$$$$$F_{1} = A$$$$$$ $$$$$$F_{2} = B$$$$$$ $$$$$$F_{i} = F_{i-1} \oplus F_{i-2} \ for \ all \ i \ge 3$$$$$$
The rules of the game are simple: Urjo will suddenly shout a number $$$N$$$. In order to win the game and prove he is the superior brother, Turjo must instantly shout back the exact value of the $$$N^{th}$$$ term in the sequence defined as $$$F_{N}$$$.
He needs your help to write a lightning-fast program so he can beat his brother and win the game!
Constraints
Input is given in the following format:
| Subtask | Points | Add. constraints |
| $$$1$$$ | $$$5$$$ | $$$N \le 3$$$ |
| $$$2$$$ | $$$7$$$ | $$$A = 1$$$ and $$$B = 1$$$ and $$$N \le 10$$$ |
| $$$3$$$ | $$$8$$$ | $$$N \le 20$$$ |
| $$$4$$$ | $$$10$$$ | $$$N \le 1000$$$ |
| $$$5$$$ | $$$30$$$ | $$$N \le 10^5$$$ |
| $$$6$$$ | $$$40$$$ | No additional constraints |
3 6 7
1
5 9 11
11
Example 1: $$$N=3 \quad A=6 \quad B=7$$$
Example 2: $$$N=5 \quad A=9 \quad B=11$$$
Bitwise XOR ($$$\oplus$$$) compares two numbers in their binary representation. It evaluates each pair of bits according to the following truth table:
| A | B | A $$$\oplus$$$ B |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| Name |
|---|


