Fibonacci Suffix Array
Time limit5sMemory limit512 MB
Given n, q, and m, the task finds the suffix array of the Fibonacci word fib_n at q query positions and prints each value modulo m.
Problem
The Fibonacci words are defined as follows: . is the concatenation of and .
The first few Fibonacci words are , , , , , , ,
A suffix array for a string of length is a permutation of the integers from to such that is the list of all non-empty suffixes of in lexicographical order.
Let be the suffix array of . Compute .
Input
The input contains several test cases and ends at end-of-file. Each test case has the following format.
The first line contains three integers , , and .
The second line contains integers .
Output
For each test case, print values separated by spaces.
Constraints
- The sum of over all test cases does not exceed .