int main()
{
int n = 0,m = 0;
scanf("%d %d",&n,&m);
int arr1[n][m];
int arr2[n][m];
int i = 0;
int j = 0;
int flag = 0;
for(i=0;i<n;i++)
{
for(j = 0;j<m;j++)
{
scanf("%d ",&arr1[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j = 0;j<m;j++)
{
scanf("%d ",&arr2[i][j]);
if(arr1[i][j]==arr2[i][j])
{
flag = 1;
}
else
{
flag = 0;
}
}
}
if(flag == 1)
{
printf("Yes\n");
}
else
{
printf("No\n");
}
return 0;
}