- Time limit: 1.00 s
- Memory limit: 512 MB
Today Veijo tried out the following function :
unsigned f(unsigned x) { unsigned a = 28; unsigned b = 6; unsigned c = 2017; x += a; x ^= (x >> b); x *= c; return x; }
(Note that here all variables are unsigned integers, so all arithmetic is done modulo .)
Veijo discovered that is actually reversible: for any value there is exactly one value with . There really has to be something magic about the date 2017-06-28, as this didn't seem to work if you use e.g. 2016 instead of 2017!
So Veijo thought you could maybe use for encryption; if it is reversible, it is at least in principle possible to do decryption. But alone looks a bit weak, so for extra obfuscation Veijo defined , which is iterations of fuction : for example, , , , , and so on.
Now your task is to write a program that calculates the values.
Input
The first line contains two numbers, and . Then follows lines. Line contains just one number, .
Output
Print lines of output. Line should contain just one number, .
Limits
Example
Input:
2 3 3280387012 1095513148
Output:
3347635925 1977414679
Here, for example, .