import sys input = sys.stdin.readline N,K=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) if sorted(A)!=sorted(B): print("No") exit() if K==N: if A==B or A==B[::-1]: print("Yes") else: print("No") exit() elif K>N: if A==B: print("Yes") else: print("No") exit() elif K