#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, f, price[200005], x, m;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      mp[4];
  cin >> n;
  for (i = 0; i < n; i++) cin >> price[i];
  for (i = 0; i < 2 * n; i++) {
    cin >> x;
    mp[x].push({price[i % n], i % n});
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> x;
    f = 0;
    while (!mp[x].empty() && f == 0) {
      if (price[mp[x].top().second] != 0) {
        cout << mp[x].top().first << " ";
        price[mp[x].top().second] = 0;
        f = 1;
      }
      mp[x].pop();
    }
    if (f == 0) cout << -1 << " ";
  }
  return 0;
}
