m, n = map(int, input().split()) L = list(map(int,input().split())) l = list(map(int,input().split())) if l in L: print("YES") else: print("NO")