#include <bits/stdc++.h>
using namespace std;
const int mx = 3e5 + 10;
set<pair<int, int> > st[4];
int arr[4][200010], n, m, x;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) scanf("%d", &arr[i][j]);
  }
  for (int i = 0; i < n; i++) {
    st[arr[1][i]].insert(make_pair(arr[0][i], i));
    st[arr[2][i]].insert(make_pair(arr[0][i], i));
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &x);
    if (st[x].empty())
      printf("-1");
    else {
      set<pair<int, int> >::iterator it = st[x].begin();
      printf("%d", it->first);
      int a = it->second;
      st[arr[1][a]].erase(make_pair(arr[0][a], a));
      st[arr[2][a]].erase(make_pair(arr[0][a], a));
    }
    if (i != m - 1) printf(" ");
  }
}
