#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first < b.first;
}
bool comps(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second == b.second) return a.first < b.first;
  return a.second < b.second;
}
void fastio() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
void inout() {}
int main() {
  fastio();
  inout();
  long long int n;
  cin >> n;
  long long int a[n], b[n], c[n];
  vector<vector<long long int>> v(4);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) cin >> b[i], v[b[i]].push_back(a[i]);
  for (long long int i = 0; i < n; i++) cin >> c[i], v[c[i]].push_back(a[i]);
  vector<long long int> cor(4, 0);
  for (long long int i = 0; i < 4; i++) {
    sort((v[i]).begin(), (v[i]).end());
  }
  map<long long int, long long int> avl;
  long long int m;
  cin >> m;
  long long int d[m];
  long long int x;
  for (long long int i = 0; i < m; i++) {
    cin >> x;
    while ((v[x]).size() > cor[x] && avl[v[x][cor[x]]] != 0) cor[x]++;
    if ((v[x]).size() > cor[x]) {
      cout << v[x][cor[x]] << " ";
      avl[v[x][cor[x]]] = 1;
      cor[x]++;
    } else {
      cout << -1;
    }
    cout << "\n";
    ;
  }
  cout << "\n";
  ;
  return 0;
}
