QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 10

#10385. Declining Sequences [B]

Statistics

Consider an integer sequence $ a_{1}, a_{2}, \ldots, a_{n} $. A (strictly) increasing sequence of indices $ c_{1}, c_{2}, \ldots, c_{p} $, where $1 ≤ c_{i} ≤ n $, is called declining if $ a_{c_{1}} > a_{c_{2}} > \ldots > a_{c_{p}}$.

A sequence of indices $ c_{1}, c_{2}, \ldots, c_{p} $ is lexicographically smaller od than a sequence of indices $ d_{1}, d_{2}, \ldots, d_{p} $ if for some $ k \in [1,p]$ it holds that $ c_{i} = d_{i} $ for each $ i \in [1,k-1] $ and $ c_{k} < d_{k} $.

Your task is to answer several queries of the form: find the (lexicographically) $ k $-th smallest declining sequence of indices.

Input Format

The first line of the standard input contains three integers $ n $, $ p $ and $ q $ ($1 ≤ n, q ≤ 100 000$, $1 ≤ p ≤ 10$) that denote the length of the sequence ($ a_{i} $), the length of the considered declining sequences and the number of queries. The second line contains $ n $ integers $ a_{i} $ ($-10^{9} ≤ a_{i} ≤ 10^{9} $). The following $ q $ lines contain descriptions of the queries: the $ j $-th of these lines contains a single integer $ k_{j} $ ($1 ≤ k_{j} ≤ 10^{18}$).

Output Format

Your program should write $ q $ lines to the standard output. The $ j $-th line should contain the $ k_{j} $-th smallest declining sequence of indices or a single number -1 if the requested declining sequence does not exist.

Example

Input

5 3 3
-1 6 5 2 1
1
5
3

Output

2 3 4 
-1
2 4 5

Notes

The declining sequences of indices of length 3 in this example are, in the lexicographical order, as follows: (2, 3, 4), (2, 3, 5), (2, 4, 5) and (3, 4, 5).

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.