#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <queue>
#define rep(i, l, r) for(int i = l; i <= r; i++)
#define down(i, l, r) for(int i = l; i >= r; i--)
#define MS 12345
#define MAX 1037471823
using namespace std;
int m[MS], n, l, r, c, k[MS], t[MS], a, b[MS], q;
void DFS(int x, int o)
{
if (x != 0) { if (o != 1) printf("%d ", m[x]); else printf("%d\n", m[x]); }
o--; if (o == 0) return;
rep(i, x+1, n) if (t[i] >= o && m[i] > m[x]) { DFS(i, o); return; }
if (x == 0) printf("Impossible\n");
}
int main()
{
scanf("%d", &n);
rep(i, 1, n) scanf("%d", &m[i]); k[0] = MAX; c = 0;
down(i, n, 1)
{
l = 0, r = c;
while (r > l)
{
if (m[i] < k[(l+r+1)/2]) l = (l+r+1)/2; else r = (l+r+1)/2-1;
}
t[i] = l+1; k[t[i]] = max(k[t[i]], m[i]); if (l+1 > c) c++;
}
scanf("%d", &q); m[0] = -MAX;
rep(i, 1, q)
{
scanf("%d", &a);
DFS(0, a+1);
}
return 0;
}
I2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxjbWF0aD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxxdWV1ZT4KCiNkZWZpbmUgcmVwKGksIGwsIHIpIGZvcihpbnQgaSA9IGw7IGkgPD0gcjsgaSsrKQojZGVmaW5lIGRvd24oaSwgbCwgcikgZm9yKGludCBpID0gbDsgaSA+PSByOyBpLS0pCiNkZWZpbmUgTVMgMTIzNDUKI2RlZmluZSBNQVggMTAzNzQ3MTgyMwoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtW01TXSwgbiwgbCwgciwgYywga1tNU10sIHRbTVNdLCBhLCBiW01TXSwg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