#include<bits/stdc++.h> #define int long long #define ll long long usingnamespace std;
constint N = 1e4 + 6;
int n, m, maxv; int a[N], f[N];
signedmain() { int i, j; n = read(); for (i = 1; i <= n; ++ i) a[i] = read(); for (i = n; i >= 1; -- i) { f[i] = 1; for (j = i + 1; j <= n; ++ j) if (a[j] > a[i]) f[i] = max(f[i], f[j] + 1); maxv = max(maxv, f[i]); } m = read(); while (m --) { int l = read(); if (l > maxv) {puts("Impossible"); continue;} int las = -1; for (i = 1; i <= n; ++ i) { if (f[i] >= l && a[i] > las) { put(a[i]), las = a[i]; if (! -- l) break; } } puts(""); } return0; }