#include <bits/stdc++.h>
using namespace std;
const int INT_INF = 0x3f3f3f3f;
const long long LL_INF = 1LL << 62;
const int maxn = 2e5 + 5;
int p[maxn], a[maxn], b[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", p + i);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++) scanf("%d", b + i);
  set<int> S[4];
  for (int i = 0; i < n; i++) {
    S[a[i]].insert(p[i]);
    S[b[i]].insert(p[i]);
  }
  int m;
  scanf("%d", &m);
  int c;
  cin >> c;
  if (!S[c].empty()) {
    int q = *S[c].begin();
    cout << q;
    for (int i = 1; i <= 3; i++) {
      if (S[i].count(q)) S[i].erase(q);
    }
  } else
    cout << -1;
  m--;
  while (m--) {
    int c;
    cin >> c;
    if (!S[c].empty()) {
      int q = *S[c].begin();
      cout << ' ' << q;
      for (int i = 1; i <= 3; i++) {
        if (S[i].count(q)) S[i].erase(q);
      }
    } else
      cout << ' ' << -1;
  }
  cout << endl;
  return 0;
}
