m, n = map(int, input().split()) L = list(map(int,input().split())) l = list(map(int,input().split())) boo = False for i in l: if i in L: boo = True else: break if boo: print("Yes") else: print("No")