A new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers pi, ai and bi, where pi is the price of the i-th t-shirt, ai is front color of the i-th t-shirt and bi is back color of the i-th t-shirt. All values pi are distinct, and values ai and bi are integers from 1 to 3.

m buyers will come to the shop. Each of them wants to buy exactly one t-shirt. For the j-th buyer we know his favorite color cj.

A buyer agrees to buy a t-shirt, if at least one side (front or back) is painted in his favorite color. Among all t-shirts that have colors acceptable to this buyer he will choose the cheapest one. If there are no such t-shirts, the buyer won't buy anything. Assume that the buyers come one by one, and each buyer is served only after the previous one is served.

You are to compute the prices each buyer will pay for t-shirts.

Input

The first line contains single integer n (1 ≤ n ≤ 200 000) — the number of t-shirts.

The following line contains sequence of integers p1, p2, ..., pn (1 ≤ pi ≤ 1 000 000 000), where pi equals to the price of the i-th t-shirt.

The following line contains sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 3), where ai equals to the front color of the i-th t-shirt.

The following line contains sequence of integers b1, b2, ..., bn (1 ≤ bi ≤ 3), where bi equals to the back color of the i-th t-shirt.

The next line contains single integer m (1 ≤ m ≤ 200 000) — the number of buyers. 

The following line contains sequence c1, c2, ..., cm (1 ≤ cj ≤ 3), where cj equals to the favorite color of the j-th buyer. The buyers will come to the shop in the order they are given in the input. Each buyer is served only after the previous one is served.

Output

Print to the first line m integers — the j-th integer should be equal to the price of the t-shirt which the j-th buyer will buy. If the j-th buyer won't buy anything, print -1.

Examples

Input

5
300 200 400 500 911
1 2 1 2 3
2 1 3 2 1
6
2 3 1 2 1 1


Output

200 400 300 500 911 -1 


Input

2
1000000000 1
1 1
1 2
2
2 1


Output

1 1000000000 
import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import java.math.BigInteger;

@SuppressWarnings("unchecked")
public class Main {

	static boolean fileIO = false;
	static boolean DEBUG = false;
	
	

	final static int INF = 0x7FFFFFFF;
	final static int MOD = (int)1e9 + 7;

	static class PII {
		int fs;
		int sc;
		int id;
		public PII(int fs, int sc, int id) { this.fs = fs; this.sc = sc; this.id = id; }
		public PII(int fs, int sc) { this.fs = fs; this.sc = sc; this.id = -1; }
		@Override
		public String toString() { return Integer.toString(fs) + " " + Integer.toString(sc); }
	}

	public static void main(String args[]) throws IOException {
		InputStream is = null;
		OutputStream os = null;
		if (fileIO) {
			is = new FileInputStream("input.txt");
			os = new FileOutputStream("output.txt");
		} else {
			is = System.in;
			os = System.out;
		}
		InputReader in = new InputReader(is);
		PrintWriter out = new PrintWriter(os);
		new Task_B().solve(in, out);
		out.close();
	}

	static class Task_A {

		public void solve(InputReader in, PrintWriter out) {
			int n = in.nI();
			int t = in.nI();
			int k = in.nI();
			int d = in.nI();
			//
			int time1 = 0;
			int cnt1 = 0;
			while (cnt1 < n) {
				time1 += t;
				cnt1 += k;
			}
			//
			if (time1 - 1 - d >= t) {
				out.println("YES");
			} else {
				out.println("NO");
			}
		}
	}

	static class X implements Comparable< X > {
		int price;
		int a;
		int b;
		int id;
		public X(int price) {
			this.price = price;
		}
		public X(int price, int a, int b, int id) {
			this.price = price;
			this.a = a;
			this.b = b;
			this.id = id;
		}

		@Override
		public int compareTo(X rhs) {
			return price - rhs.price;
		}
		@Override
		public boolean equals(Object rhs) {
			if (this == rhs) return true;
			if (rhs == null) return false;
			if (getClass() != rhs.getClass()) return false;
			return price == ((X)rhs).id;
		}
	}

	static class Task_B {

		int n;
		int m;
		X s[];

		NavigableSet< X > one;
		NavigableSet< X > two;
		NavigableSet< X > three;

		public void solve(InputReader in, PrintWriter out) {
			n = in.nI();
			s = new X[n];
			for (int i = 0; i < n; i++) {
				s[i] = new X(in.nI());
			}
			for (int i = 0; i < n; i++) {
				s[i].a = in.nI();
			}
			for (int i = 0; i < n; i++) {
				s[i].b = in.nI();
			}
			one = new TreeSet<>();
			two = new TreeSet<>();
			three = new TreeSet<>();
			for (int i = 0; i < n; i++) {
				if (s[i].a == 1 || s[i].b == 1) one.add(s[i]);
				if (s[i].a == 2 || s[i].b == 2) two.add(s[i]);
				if (s[i].a == 3 || s[i].b == 3) three.add(s[i]);
			}
			//
			int m = in.nI();
			while (m-- > 0) {
				int c = in.nI();
				if (c == 1) {
					if (one.size() > 0) {
						X rm = one.pollFirst();
						two.remove(rm);
						three.remove(rm);
						out.print(rm.price);
					} else {
						out.print(-1);
					}
					out.print(" ");
				} else if (c == 2) {
					if (two.size() > 0) {
						X rm = two.pollFirst();
						one.remove(rm);
						three.remove(rm);
						out.print(rm.price);
					} else {
						out.print(-1);
					}
					out.print(" ");
				} else if (c == 3) {
					if (three.size() > 0) {
						X rm = three.pollFirst();
						one.remove(rm);
						two.remove(rm);
						out.print(rm.price);
					} else {
						out.print(-1);
					}
					out.print(" ");
				}
			}
		}
	}

	static class Yandex {

		char s[] = "СОЛНЦЕ".toCharArray();
		List< char[] > ans = new LinkedList<>();

		public void solve(InputReader in, PrintWriter out) {
			permutation(0, s.length - 1);
			int cnt = 0;
			for (char ss[] : ans) {
				char order[] = new char[4];
				char pattern[] = new char[] { 'С', 'Л', 'Н', 'Ц' };
				int i = 0;
				for (char c : ss)
					if (c == 'С' || c == 'Л' || c == 'Н' || c == 'Ц')
						order[i++] = c;
				if (Arrays.equals(order, pattern)) {
					cnt++;
					out.println(ss);
				}
			}
			out.println(cnt);
		}

		private void permutation(int l, int r) {
			if (l == r) {
				ans.add(Arrays.copyOfRange(s, 0, s.length));
			} else {
				char tmp;
				for (int i = l; i <= r; i++) {
					tmp = s[l];
					s[l] = s[i];
					s[i] = tmp;
					//
					permutation(l + 1, r);
					//
					tmp = s[l];
					s[l] = s[i];
					s[i] = tmp;
				}
			}
		}
	}

	static class Vectors {

		int v1[] = { 0, 0, 3 };
		int v2[] = { 4, 5, 5 };
		int v3[] = { 1, 3, 2 };
		int v4[] = { 5, 4, 5 };
		int v5[] = { 0, 0, 4 };

		List< int[] > vec = new LinkedList<>();

		public void solve(InputReader in, PrintWriter out) {
			vec.add(Arrays.copyOf(v1, v1.length));
			vec.add(Arrays.copyOf(v2, v2.length));
			vec.add(Arrays.copyOf(v3, v3.length));
			vec.add(Arrays.copyOf(v4, v4.length));
			vec.add(Arrays.copyOf(v5, v5.length));
			int ans = 0;
			for (int i = 0; i < vec.size() - 2; i++)
				for (int j = i + 1; j < vec.size() - 1; j++)
					for (int k = j + 1; k < vec.size(); k++)
						if (ok(i, j, k)) ans++;
			out.println(ans);
			
		}

		boolean ok(int i1, int i2, int i3) {
			int a[] = vec.get(i1);
			int b[] = vec.get(i2);
			int c[] = vec.get(i3);
			boolean ret = true;
			if (a[1] * b[2] - a[2] * b[1] == 0 &&
				a[0] * b[2] - a[2] * b[0] == 0 &&
				a[0] * b[1] - a[1] * b[0] == 0) ret = false;
			if (b[1] * c[2] - b[2] * c[1] == 0 &&
				b[0] * c[2] - b[2] * c[0] == 0 &&
				b[0] * c[1] - b[1] * c[0] == 0) ret = false;
			if (a[1] * c[2] - a[2] * c[1] == 0 &&
				a[0] * c[2] - a[2] * c[0] == 0 &&
				a[0] * c[1] - a[1] * c[0] == 0) ret = false;
			return ret;
		}
	}


	static class Task {

		int a[] = new int[] { 1, 3, 3, 3, 5, 12 };
		int q = 3;

		public void solve(InputReader in, PrintWriter out) {
			SegmentTree st = new SegmentTree(a);
			for (int i = 0; i < a.length; i++) out.print(i + " ");
			out.println();
			for (int i = 0; i < a.length; i++) out.print(a[i] + " ");
			out.println();
			//
			while (q-- > 0) {
				int i = new Random().nextInt(a[a.length - 1]);
				int j = new Random().nextInt(a[a.length - 1]);
				if (j < i) {
					int tmp = i;
					i = j;
					j = tmp;
				}
				out.println("sum[" + i + " " + j + "] = " + st.query(i, j));
			}

		}
	}

	static class SegmentTree {

		private static int NIL = 0x7FFFFFFF;
		private int n;
		private int st[];
		private int sz;

		public SegmentTree(int a[]) {
			n = a.length;
			sz = 1;
			while (sz < n) sz <<= 1;
			sz *= 2;
			st = new int[sz];
			st[1] = build(a, 1, 0, n - 1);
		}

		private int build(int a[], int id, int i, int j) {
			if (i == j) {
				st[id] = a[i];
			} else {
				int m = (i + j) >> 1;
				st[id] = build(a, id << 1, i, m) + build(a, (id << 1) + 1, m + 1, j);
			}
			return st[id];
		}

		public int query(int i, int j) {
			return query(1, 0, n - 1, i, j);
		}

		// @id -> node's id of tree
		// @ (l r) -> interval corresponding to @id node
		// @ (i j) -> querying sum
 		private int query(int id, int l, int r, int i, int j) {
 			if (r < i || l > j) return NIL;
 			if (i <= l && j >= r) {
 				return st[id];
 			} else {
 				int m = (l + r) >> 1;
 				int ql = query(id << 1, l, m, i, j);
 				int qr = query((id << 1) + 1, m + 1, r, i, j);
 				return ql == NIL ? qr : qr == NIL ? ql : ql + qr;
 			}
		}

		public void update(int i, int value) {
			update(1, 0, n - 1, i, value);
		}

		private void update(int id, int l, int r, int i, int value) {
			if (l == r) {
				st[id] = value;
			} else {
				int m = (l + r) >> 1;
				update(id << 1, l, m, i, value);
				update((id << 1) + 1, m + 1, r, i, value);
			}
		}

	}


	static class InputReader {

		private StringTokenizer tokenizer;
		private BufferedReader reader;

		public InputReader(InputStream is) {
			tokenizer = null;
			reader = new BufferedReader(new InputStreamReader(is), 32768);
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					if (line == null) return null;
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public String nextLine() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					if (line == null) return null;
					tokenizer = new StringTokenizer(line, "\n");
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public Integer nI() { return Integer.parseInt(next()); }
		public Integer[] nIA(int n) {
			Integer ret[] = new Integer[n];
			int i = 0;
			while (n-- > 0) ret[i++] = nI();
			return ret;
		}
		public Long nL() { return Long.parseLong(next()); }
		public Long[] nLA(int n) {
			Long ret[] = new Long[n];
			int i = 0;
			while (n-- > 0) ret[i++] = nL();
			return ret;
		}
	}
}