def find(a, b): for i in b: c=0 for j in a: if i == j: c+=1 print('YES') break if c ==0: print('NO') while True: try: n = int(input()) L = list(map(int, input().split())) p = int(input()) L1 = list(map(int, input().split())) find(L, L1) except: break