#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m, x, u, v;
int a[maxn], b[maxn], p[maxn];
map<int, pair<int, int> > col;
set<int> q[4];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) {
    col[p[i]] = make_pair(a[i], b[i]);
    q[a[i]].insert(p[i]);
    q[b[i]].insert(p[i]);
  }
  scanf("%d", &m);
  while (m--) {
    scanf("%d", &x);
    if (q[x].empty())
      printf("-1 ");
    else {
      int pr = *q[x].begin();
      printf("%d ", pr);
      u = col[pr].first;
      v = col[pr].second;
      q[u].erase(pr);
      q[v].erase(pr);
    }
  }
  return 0;
}
