Evaluating recurrences ---------------------- You are given a very simple recurrence: x[0] = 10, x[t+1] = (A*x[t] + B ) mod M, for t>0, and for given integers A, B, M. In this problem, you are asked to compute x[t] for different t. To make things simple you are told that M=2^20. Input ----- The input will a line containing the integers A and B followed by m lines, each containing a single instance. Each instance is a single integer n>0, for which you must output x[n]. You may assume that A, B fit in a long integer. You are also given that n<= 10000, and the number of instances m <= 10000. The end of the input will be indicated by a line containing 0. This case should not be processed. Output ------ The output should contain one line for each case. Each line should have a single integer x[n]. Sample input ------------ 4 6 1 2 0 Sample output ------------- 46 190