import sys from collections import defaultdict def main(): input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx +=1 k = int(input[idx]) idx +=1 A = list(map(int, input[idx:idx+N])) idx +=N B = list(map(int, input[idx:idx+N])) idx +=N # Check if A and B have the same elements count_A = defaultdict(int) count_B = defaultdict(int) for a in A: count_A[a] +=1 for b in B: count_B[b] +=1 if count_A != count_B: print("No") return if k ==1: print("Yes") return if k > N: if A == B: print("Yes") else: print("No") return # If k <=N, then answer is Yes because it's possible. print("Yes") if __name__ == "__main__": main()