Time limit
2s
Memory limit
128 MB
An infinite sequence S is defined as follows.
S_0 = firstS_1 = secondS_i = |S_{i-2} - S_{i-1}| for i >= 2You are given first, second, and the number of queries N. For each query index i, output the value of S_i.
The first line contains first, second, and the number of queries N.
Each of the next N lines contains one query. A query is an integer i, and its answer is S_i.
N is a positive integer no greater than 50. first, second, and every query index i are non-negative integers no greater than 10^18.
For each query, output S_i on its own line, in the same order as the input queries.