Time limit: 1s
Memory limit: 64MB
Input:
Output:
Consider the following integer sequence :
, , for .
Now, you are wondering, for triples of integers (), what is the sum of all , , modulo . That is, find and print it's remainder modulo .
By we denote the absolute value of and by we denote the bitwise XOR operation.
Input data
In the first line of input, you will read one integer ().
In the next lines, you will read three integers , () and (, is prime).
Output data
Output lines, the of them representing the answer for the triple ().
Example
stdin
4
1 3 998244353
2 4 998244353
4232324 12345678 998244353
92345678 998244353 998244353
stdout
4
5
652671816
367684397
Explanation
The first four values of are: .
Thus, the answer for the first question is and the answer for the second question is .