#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9 + 10;
const int mod = (int)1e9 + 7;
const int N = (int)1e6 + 10;
const long long LLINF = (long long)1e18 + 10;
const double pi = acos(-1.0);
template <typename T1, typename T2>
bool umin(T1 &x, T2 y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, T2 y) {
  if (x < y) return x = y, true;
  return false;
}
template <typename T>
T getint() {
  char c = getchar();
  T p = 1, x = 0;
  while (c == ' ' || c == '\n') c = getchar();
  if (c == '-') p = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * p;
}
int a[N], b[N], p[N];
multiset<pair<int, int> > s[4];
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  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];
  for (int i = 0; i < n; ++i) {
    s[a[i]].insert(make_pair(p[i], i));
    s[b[i]].insert(make_pair(p[i], i));
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int c;
    cin >> c;
    if (!s[c].size()) {
      cout << "-1 ";
      continue;
    }
    pair<int, int> x = *s[c].begin();
    cout << x.first << ' ';
    s[a[x.second]].erase(s[a[x.second]].find(make_pair(x.first, x.second)));
    s[b[x.second]].erase(s[b[x.second]].find(make_pair(x.first, x.second)));
  }
  return 0;
}
