#include <bits/stdc++.h>
using namespace std;
vector<int> cnt[10];
int pos[10], p[200005], a[200005], b[200005];
void load() {}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    cnt[(a[i] - 1) * 3 + b[i] - 1].push_back(p[i]);
  }
  for (int i = 0; i < 10; i++) {
    sort(cnt[i].begin(), cnt[i].end());
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int c;
    cin >> c;
    c--;
    int t = -1, val = -1;
    for (int j = 0; j < 3; j++) {
      int pp = j * 3 + c;
      if (pos[pp] < (int)cnt[pp].size() &&
          (t == -1 || val > cnt[pp][pos[pp]])) {
        t = pp;
        val = cnt[pp][pos[pp]];
      }
      pp = c * 3 + j;
      if (pos[pp] < (int)cnt[pp].size() &&
          (t == -1 || val > cnt[pp][pos[pp]])) {
        t = pp;
        val = cnt[pp][pos[pp]];
      }
    }
    if (i > 0) cout << " ";
    if (t == -1) {
      cout << "-1";
      continue;
    }
    cout << val;
    pos[t]++;
  }
  cout << endl;
}
int main() {
  load();
  solve();
  return 0;
}
