#include <bits/stdc++.h>
using namespace std;
long long n, i, flag = 0, 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];
void input() {
  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});
  }
}
void solve() {
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> x;
    int flag = 0;
    while (!mp[x].empty() && flag == 0) {
      if (price[mp[x].top().second] != 0) {
        cout << mp[x].top().first << " ";
        price[mp[x].top().second] = 0;
        flag = 1;
      }
      mp[x].pop();
    }
    if (flag == 0) cout << -1 << " ";
  }
}
int main() {
  input();
  solve();
  return 0;
}
