n, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) # Check if a and b are permutations of each other if sorted(a) != sorted(b): print("No") else: if k > n: # Can't perform any operation. Check if a equals b if a == b: print("Yes") else: print("No") else: if k <= 2: print("Yes") else: if n >= k + 1: print("Yes") else: print("No")