so easy 一把过

row,col = map(int,input().split())
a= [[0 for _ in range(0,row+10)]for _ in range(0,col+10) ]
b=[[0 for _ in range(0,row+10)]for _ in range(0,col+10) ]
for i in range(0,row):
    a[i]=list(map(int,input().split()))
for i in range(0,row):
    b[i]=list(map(int,input().split()))
    
flag = 0
for i in range(0,row):
    for j in range(0,col):
        if (a[i][j]!=b[i][j]):
            flag=-1
            break
if flag == 0:
    print("Yes")
else:
    print("No")