풀이시간: 15분
# 5분
N = int(input())
have_card = list(map(int, input().split()))
M = int(input())
check_list = list(map(int, input().split()))
ans = []
for ch_num in check_list:
if ch_num in have_card:
ans.append('1')
else:
ans.append('0')
print(' '.join(ans))
# 10분
from bisect import bisect_left, bisect_right
N = int(input())
have_card = sorted(list(map(int, input().split())))
M = int(input())
check_list = list(map(int, input().split()))
ans = []
for ch_num in check_list:
if abs(bisect_left(have_card, ch_num) - bisect_right(have_card, ch_num)):
ans.append('1')
else:
ans.append('0')
print(' '.join(ans))
N = int(input())
cards = sorted(list(map(int, input().split())))
M = int(input())
qry = list(map(int, input().split()))
ans = []
for q in qry:
l = bisect_left(cards, q)
r = bisect_right(cards, q)
ans.append(1 if r - l else 0)
print(*ans)