#include <bits/stdc++.h>
using namespace std;
int cnt[1000000 + 1];
const int mod = 1e9 + 7;
vector<int> v;
char a[1010];
char b[1010];
void solve() {
  int n;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) cin >> p[i];
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<pair<int, int>> v;
  map<int, vector<int>> ma;
  for (int i = 0; i < n; i++) {
    ma[p[i]].push_back(a[i]);
    ma[p[i]].push_back(b[i]);
  }
  set<int> st[4];
  for (int i = 0; i < n; i++) {
    st[a[i]].insert(p[i]);
    st[b[i]].insert(p[i]);
  }
  int m;
  cin >> m;
  int c[m];
  for (int i = 0; i < m; i++) {
    cin >> c[i];
    int k = st[c[i]].size();
    bool ok = true;
    while (k) {
      auto j = st[c[i]].begin();
      if (ma.find(*j) != ma.end()) {
        ok = false;
        cout << *j << " ";
        ma.erase(*j);
        st[c[i]].erase(*j);
        break;
      } else {
        st[c[i]].erase(*j);
      }
      k--;
    }
    if (ok) cout << -1 << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
