n,k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) if a== b: print('Yes') exit() if k >= n and a != b[::-1]: print('No') exit() if k == n: print('Yes') exit() if sorted(a) == sorted(b): print('Yes') exit() print('No')