/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C/C++.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int main()
{
//1 --> azul, 2 --> verde, 3 --> negro
set<int> azul;
set<int> verde;
set<int> negro;
int t;
cin >> t;
vector<int> b(t);
int a;
for (int i = 0; i < t; ++i) cin >> b[i];
for (int i = 0; i < t; ++i) {
cin >> a;
if (a == 1) azul.insert(b[i]);
else if (a == 2) verde.insert(b[i]);
else negro.insert(b[i]);
}
for (int i = 0; i < t; ++i) {
cin >> a;
if (a == 1) azul.insert(b[i]);
else if (a == 2) verde.insert(b[i]);
else negro.insert(b[i]);
}
cin >> t;
int n;
for (int i = 0; i < t; ++i) {
cin >> a;
if (a == 1) {
if (azul.empty()) cout << -1 << ' ';
else {
cout << *azul.cbegin() << ' ';
azul.erase(*azul.cbegin());
}
}
else if (a == 2) {
if (verde.empty()) cout << -1 << ' ';
else {
cout << *verde.cbegin() << ' ';
verde.erase(*verde.cbegin());
}
}
else {
if (negro.empty()) cout << -1 << ' ';
else {
cout << *negro.cbegin() << ' ';
negro.erase(*negro.cbegin());
}
}
}
return 0;
}