Suffix Array for Fibonacci
题号:NC213138
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

The sequence of Fibonacci words is defined as follows: . fib_n is the concatenation of and .

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 is the list of non-empty suffixes of s sorted in lexicographical order.

Let sa be the suffix array for fib_n. You task is to calculate the value of .

输入描述:

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 .

*
*
*
*
* The sum of q does not exceed .

输出描述:

For each test case, output q values , separated by spaces.
示例1

输入

复制
1 1 10
1
2 2 10
1 2
3 3 10
1 2 3
4 5 10
1 2 3 4 5
5 8 10
1 2 3 4 5 6 7 8

输出

复制
1 
1 2 
3 1 2 
3 4 1 5 2 
8 3 6 1 4 7 2 5