Sam was staying up late one night, trying to analyze her research data. Unfortunately, in her sleep-deprived state, she forgot to save her work and it was eaten by some fast-moving cobras! Luckily, she remembers that she had generated her
For precise details on how the generator works, read the pseudocode below.
Generator Pseudocode
Copy
x = 0
for i in range(n):
x *= a
x += b
x %= m
data[i] = x
Input Format
The only line of input consists of four integers:
Output Format
Output a single integer: the bitwise-xor of all the data values.
Constraints
Sample Input
Copy
1000 6 1 65536
Sample Output
Copy
22478
Comments