n,m = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) i,j =0, 0 while j < m and i < n: if b[j] == a[i]: i+=1 j+=1 print('Yes' if i == n else 'No')