import sys N = int(input()) li1 = set(sys.stdin.readline().rstrip().split()) M = int(input()) answer = '' for i in sys.stdin.readline().rstrip().split(): if(i in li1): answer+= '1 ' else : answer += '0 ' print(answer)