# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ## 2021년 9월 4일 토요일
# ### BaekJoon - 암기왕 (Python)
# ### 문제 : https://www.acmicpc.net/problem/2776
# ### 블로그 : https://somjang.tistory.com/entry/BaekJoon-2776%EB%B2%88-%EC%95%94%EA%B8%B0%EC%99%95-Python

# ### Solution

# +
def memorization_king(note1, note2):
    note1 = set(map(int, note1.split()))
    note2 = list(map(int, note2.split()))
    
    for post in note2:
        if post in note1:
            print(1)
        else:
            print(0)
    
    
if __name__ == "__main__":
    for _ in range(int(input())):
        note1_num = int(input())
        note1 = input()
        note2_num = int(input())
        note2 = input()
        
        memorization_king(note1, note2)

StarcoderdataJupyterScriptsDedupFiltered