题目描述
Problem Description
For a given sequence \( S = \{a_1, a_2, a_3, \ldots, a_n\} \), if there exists a subsequence \( P = \{a_{x_1}, a_{x_2}, a_{x_3}, \ldots, a_{x_m}\} \) such that \( (x_1 < x_2 < \ldots < x_m) \) and \( (a_{x_1} < a_{x_2} < \ldots < a_{x_m}) \), then \( P \) is called an ascending subsequence of \( S \). If there are multiple such subsequences \( P \), we want to find the one with the smallest lexicographical order.
Task:
Given the sequence \( S \) and several queries. For the \( i \)-th query, find an ascending subsequence of length \( L_i \). If there are multiple such subsequences, find the one with the smallest lexicographical order (i.e., first minimize \( x_1 \), then if not unique, minimize \( x_2 \), and so on). If no such subsequence of length \( L_i \) exists, print Impossible.
Input Format
The first line contains an integer \( N \), representing the number of elements in the sequence.
The second line contains \( N \) numbers, \( a_1, a_2, \cdots, a_n \).
The third line contains an integer \( M \), representing the number of queries. The following \( M \) lines each contain an integer \( L \), representing the length of the ascending subsequence to be queried.
Output Format
For each query, if the corresponding subsequence exists, output it; otherwise, print Impossible.
Sample Input and Output
Input Sample #1
6
3 4 1 2 3 6
3
6
4
5
Output Sample #1
Impossible
1 2 3 6
Impossible
Input Sample #2
6
6 7 1 2 3 4
1
2
Output Sample #2
6 7
Notes
\( N \leq 10000 \), \( M \leq 1000 \). The data is guaranteed to be random.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分