#include <bits/stdc++.h>
using namespace std;
bool isBought[200007];
int P[200007];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    Q[7];
int main() {
  int i, j, k, l, m, n, t, d, x, y, z, a, b, r, q;
  pair<int, int> temp;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &P[i]);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    Q[a].push(make_pair(P[i], i));
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    Q[a].push(make_pair(P[i], i));
  }
  scanf("%d", &m);
  for (i = 1; i <= m; i++) {
    scanf("%d", &a);
    bool flag = false;
    while (!Q[a].empty()) {
      temp = Q[a].top();
      Q[a].pop();
      if (isBought[temp.second]) continue;
      isBought[temp.second] = true;
      printf("%d ", temp.first);
      flag = true;
      break;
    }
    if (!flag) printf("-1 ");
  }
  printf("\n");
  return 0;
}
