#include<sdtio.h>
int main()
{
int n = 0;//行
int m = 0;//列
int arr1[11][11] = { 0 };//存储第一次元素
int arr2[11][11] = { 0 };//存储第二次元素
while ((scanf_s("%d %d",&n,&m))!=EOF)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
scanf_s("%d", &arr1[i][j]);//第一次元素
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
scanf_s("%d", &arr2[i][j]);//第二次元素
}
}
//进行比较
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (arr1[i][j] != arr2[i][j])
{
printf("No");
return 0;
}
}
}
printf("Yes");
}
return 0;
}