#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, SZ = 2e5 + 5;
int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, -1, 1, 0};
int dxx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dyy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
vector<pair<int, pair<int, int> > > gr[SZ];
int col_idx[4];
int idx[SZ];
int main() {
  int i, j, n, m, k;
  scanf("%d", &n);
  int p[n], a[n], b[n];
  for (i = 0; i < n; i++) scanf("%d", &p[i]);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) scanf("%d", &b[i]);
  for (i = 0; i < n; i++) {
    gr[a[i]].push_back(make_pair(p[i], make_pair(b[i], i)));
    gr[b[i]].push_back(make_pair(p[i], make_pair(a[i], i)));
  }
  for (i = 0; i < 4; i++) sort(gr[i].begin(), gr[i].end());
  scanf("%d", &m);
  int q[m];
  for (i = 0; i < m; i++) {
    scanf("%d", &q[i]);
  }
  for (i = 0; i < m; i++) {
    int fl = 0;
    for (j = col_idx[q[i]]; j < gr[q[i]].size();) {
      if (!idx[gr[q[i]][j].second.second]) {
        idx[gr[q[i]][j].second.second] = 1;
        col_idx[q[i]] = j + 1;
        q[i] = gr[q[i]][j].first;
        fl = 1;
        break;
      } else
        j++;
    }
    if (!fl) q[i] = -1;
  }
  for (i = 0; i < m; i++) printf("%d ", q[i]);
  printf("\n");
  return 0;
}
