n, k = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) if k == 1 or k > n: print("Yes" if A == B else "No") else: from collections import Counter print("Yes" if Counter(A) == Counter(B) else "No")