EC_SER  Progression
Let S be an infinite sequence of integers:
S_{0} = a;
S_{1} = b;
S_{i} = S_{i2}  S_{i1} for all i >= 2.
You have two integers a and b. You must answer some queries about the nth element in the sequence
Input
The first line contains a and b (0 <= a, b <= 10^18).
The second line contains a integer q (1 <= q <= 100000).
The third contains q integers q_{i}.
Output
For each q_{i} you must print a line with the q_{i}th element of S.
Example
Input: 21 12 5 0 1 2 3 4 Output: 21 12 9 3 6
Note: the values of q_{i} are in the range of 64 bits.
hide comments
:D:
20161002 18:06:42
The trick here is to limit the amount of cases you need to analyze. There are not that many that require encoding if proper reductions are used. Nice problem. 

Raghav Aggiwal:
20140928 12:26:58
finally!! easy but requires a lot of analysis .. there will be hell lot of cases.. Last edit: 20140929 16:38:56 

wisfaq:
20140905 21:50:58
Dear Eddy, could you please make all your problems available for all languages. I really can't understand why you're keeping to those language restrictions Last edit: 20140905 21:52:22 
Added by:  Eddy Cael 
Date:  20140905 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  C CPP C++ 4.3.2 JAVA 
Resource:  Internas UTO 2014 