#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n], b[n], c[n];
  set<long long> s[4];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    s[b[i]].insert(a[i]);
  }
  for (long long i = 0; i < n; i++) {
    cin >> c[i];
    s[c[i]].insert(a[i]);
  }
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long tmp;
    cin >> tmp;
    if (s[tmp].empty()) {
      cout << -1 << " ";
    } else {
      long long ele = *s[tmp].begin();
      cout << ele << " ";
      for (long long j = 1; j <= 3; j++) {
        s[j].erase(ele);
      }
    }
  }
  cout << endl;
  return 0;
}
