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).

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.