data=list(map(int,input().split()))
n=2*len(data)
hashlst=[0 for i in range(n)]
for item in data:
pos=__________
while __________:
__________
__________
m=int(input())
for i in range(m):
num=int(input())
k=__________
while __________:
__________
if hashlst[k]==num:
print(1)
else:
print(0)