This page is still under construction.

Parts of this page are still being built. What you see may change.

Declining Sequences

Time limit1sMemory limit128 MB

Summary
Given a sequence and a fixed length p, count and return the lexicographically k-th decreasing index sequence for each query.
Level

Hard8 of 10

Topics
Dynamic programming, Combinatorics, Binary search
Solved
No attempts yet

Problem

Consider an integer sequence a1,a2,…,ana_1, a_2, \ldots, a_n. A strictly increasing sequence of indices c1,c2,…,cpc_1, c_2, \ldots, c_p (with 1≤ci≤n1 \le c_i \le n) is called declining if the values at those positions strictly decrease, that is ac1>ac2>⋯>acpa_{c_1} > a_{c_2} > \cdots > a_{c_p}.

A sequence of indices c1,c2,…,cpc_1, c_2, \ldots, c_p is lexicographically smaller than a sequence d1,d2,…,dpd_1, d_2, \ldots, d_p if there is some position k∈[1,p]k \in [1, p] such that ci=dic_i = d_i for every i∈[1,k−1]i \in [1, k-1] and ck<dkc_k < d_k.

Answer several queries of the form: find the lexicographically kk-th smallest declining sequence of indices. Every declining sequence considered has length exactly pp.

Input

The first line contains three integers nn, pp, and qq (1≤n,q≤100 0001 \le n, q \le 100\,000, 1≤p≤101 \le p \le 10): the length of the sequence, the length of the declining sequences to consider, and the number of queries. The second line contains nn integers aia_i (−109≤ai≤109-10^9 \le a_i \le 10^9). Each of the next qq lines contains one integer kjk_j (1≤kj≤10181 \le k_j \le 10^{18}).

Output

Print qq lines. The jj-th line contains the kjk_j-th smallest declining sequence of indices, written as its pp index values separated by single spaces, or a single number −1-1 if that declining sequence does not exist.

Note

For the first example (n=5n=5 and the sequence −1 6 5 2 1-1\ 6\ 5\ 2\ 1), the declining sequences of indices of length 33, in lexicographic order, are (2,3,4)(2, 3, 4), (2,3,5)(2, 3, 5), (2,4,5)(2, 4, 5), and (3,4,5)(3, 4, 5).

Examples2

  1. Example 1

    Input
    5 3 3
    -1 6 5 2 1
    1
    5
    3
    
    Expected output
    2 3 4
    -1
    2 4 5
    
  2. Example 2

    Input
    4 1 5
    3 1 2 5
    1
    2
    3
    4
    5
    
    Expected output
    1
    2
    3
    4
    -1