#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 5;
int ara[mx];
bool taken[mx];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ara[i];
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq[3];
  for (int i = 0; i < 2 * n; i++) {
    int x;
    cin >> x;
    x--;
    pq[x].push({ara[i % n], i % n});
  }
  int t;
  cin >> t;
  while (t--) {
    int x;
    cin >> x;
    x--;
    while (!pq[x].empty() && taken[pq[x].top().second]) pq[x].pop();
    if (pq[x].empty())
      cout << -1;
    else {
      cout << pq[x].top().first;
      taken[pq[x].top().second] = 1;
      pq[x].pop();
    }
    cout << " ";
  }
  cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
