#include <bits/stdc++.h>
using namespace std;
int a[200011];
int b[200011];
int p[200011];
vector<int> V[10];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  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++) {
    a[i]--;
    b[i]--;
    V[(1 << a[i]) | (1 << b[i])].push_back(p[i]);
  }
  for (int j = 0; j < 8; j++) {
    sort(V[j].begin(), V[j].end());
    reverse(V[j].begin(), V[j].end());
  }
  int m, c;
  cin >> m;
  while (m--) {
    cin >> c;
    c--;
    int b = -1;
    int cur;
    for (int j = 0; j < 3; j++) {
      cur = ((1 << j) | (1 << c));
      if (V[cur].size()) {
        if (b == -1 or V[b].back() > V[cur].back()) b = cur;
      }
    }
    if (b == -1) {
      cout << -1 << " ";
    } else {
      cout << V[b].back() << " ";
      V[b].pop_back();
    }
  }
}
