The sequence of Fibonacci words is defined as follows: fib_0=b,fib_1=a,fib_n=fib_n−1fib_n−2 for n≥2. fib_n is the concatenation of fib_n−1 and fib_n−2.
The first few Fibonacci words are: b, a, ab, aba, abaab, abaababa, abaababaabaab, …
A suffix array for string s of length n is a permutation sa of integers from 1 to n such that s\[sa_1..n],s\[sa_2..n],…,s\[sa_n..n] is the list of non-empty suffixes of s sorted in lexicographical order.
Let sa be the suffix array for fib_n. Your task is to calculate the value of (sa_p_1modm),(sa_p_2modm),…,(sa_p_qmodm).
The input consists of several test cases terminated by end-of-file. For each test case:
The first line contains three integers n, q and m.
The second line contains q integers p_1,p_2,…,p_q.
For each test case, output q values (sa_p_1modm),(sa_p_2modm),…,(sa_p_qmodm), separated by spaces.