A new pack of *n* t-shirts came to a shop. Each of the t-shirts is characterized by three integers *p*<sub class="lower-index">*i*</sub>, *a*<sub class="lower-index">*i*</sub> and *b*<sub class="lower-index">*i*</sub>, where *p*<sub class="lower-index">*i*</sub> is the price of the *i*-th t-shirt, *a*<sub class="lower-index">*i*</sub> is front color of the *i*-th t-shirt and *b*<sub class="lower-index">*i*</sub> is back color of the *i*-th t-shirt. All values *p*<sub class="lower-index">*i*</sub> are distinct, and values *a*<sub class="lower-index">*i*</sub> and *b*<sub class="lower-index">*i*</sub> 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 *c*<sub class="lower-index">*j*</sub>.

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.
The first line contains single integer *n* (1 ≤ *n* ≤ 200 000) — the number of t-shirts.

The following line contains sequence of integers *p*<sub class="lower-index">1</sub>, *p*<sub class="lower-index">2</sub>, ..., *p*<sub class="lower-index">*n*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ 1 000 000 000), where *p*<sub class="lower-index">*i*</sub> equals to the price of the *i*-th t-shirt.

The following line contains sequence of integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 3), where *a*<sub class="lower-index">*i*</sub> equals to the front color of the *i*-th t-shirt.

The following line contains sequence of integers *b*<sub class="lower-index">1</sub>, *b*<sub class="lower-index">2</sub>, ..., *b*<sub class="lower-index">*n*</sub> (1 ≤ *b*<sub class="lower-index">*i*</sub> ≤ 3), where *b*<sub class="lower-index">*i*</sub> 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 *c*<sub class="lower-index">1</sub>, *c*<sub class="lower-index">2</sub>, ..., *c*<sub class="lower-index">*m*</sub> (1 ≤ *c*<sub class="lower-index">*j*</sub> ≤ 3), where *c*<sub class="lower-index">*j*</sub> 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.
none
5
300 200 400 500 911
1 2 1 2 3
2 1 3 2 1
6
2 3 1 2 1 1
200 400 300 500 911 -1 
2
1000000000 1
1 1
1 2
2
2 1
1 1000000000 
10
251034796 163562337 995167403 531046374 341924810 828969071 971837553 183763940 857690534 687685084
3 2 1 3 2 3 1 3 2 1
2 3 3 1 2 3 2 3 3 2
10
1 3 2 3 2 3 3 1 2 3
531046374 163562337 251034796 183763940 341924810 828969071 857690534 687685084 971837553 995167403 
20
414468312 20329584 106106409 584924603 666547477 670032002 726095027 276840253 368277336 940941705 531635095 213813062 440421387 959075599 240727854 495316522 838268432 786936631 586382273 806443734
3 1 2 3 3 2 2 1 3 2 3 2 3 3 3 2 1 3 1 2
3 1 2 2 2 2 3 1 2 3 2 1 1 2 3 1 2 3 3 2
40
1 1 2 1 3 2 3 1 3 3 1 2 3 1 1 1 2 3 3 1 3 1 3 1 2 2 3 3 1 2 1 2 3 2 2 1 2 1 2 2
20329584 213813062 106106409 276840253 240727854 368277336 414468312 440421387 531635095 584924603 495316522 666547477 586382273 838268432 -1 -1 670032002 726095027 786936631 -1 940941705 -1 959075599 -1 806443734 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
1
529469903
1
3
1
3
529469903 


n = int(input())
p = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = int(input())
buyer = list(map(int, input().split()))

ans = []
s1 = set()
s2 = set()
s3 = set()

for i in range(n):
    if a[i] == 1 or b[i] == 1:
        s1.add(p[i])
    if a[i] == 2 or b[i] == 2:
        s2.add(p[i])
    if a[i] == 3 or b[i] == 3:
        s3.add(p[i])

for i in range(m):
    if buyer[i] == 1:
        if s1:
            ans.append(min(s1))
            s2.discard(min(s1))
            s3.discard(min(s1))
            s1.discard(min(s1))
        else:
            ans.append(-1)
    elif buyer[i] == 2:
        if s2:
            ans.append(min(s2))
            s1.discard(min(s2))
            s3.discard(min(s2))
            s2.discard(min(s2))
        else:
            ans.append(-1)
    elif buyer[i] == 3:
        if s3:
            ans.append(min(s3))
            s2.discard(min(s3))
            s1.discard(min(s3))
            s3.discard(min(s3))
        else:
            ans.append(-1)

for i in ans:
    print(i, end=' ')

 	 			   	   							  	 	  	