#include <iostream>
using namespace std;
int main()
{
int m, n; //m行n列
int count = 0; //相同次数
cin >> m >> n;
int arr1[10][10] = { {0} };
int arr2[10][10] = { {0} };
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cin >> arr1[i][j];
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cin >> arr2[i][j];
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if (arr1[i][j] == arr2[i][j])
{
count++;
}
}
}
if (count == m * n)
{
cout << "Yes";
}
else
{
cout << "No";
}
return 0;
}
using namespace std;
int main()
{
int m, n; //m行n列
int count = 0; //相同次数
cin >> m >> n;
int arr1[10][10] = { {0} };
int arr2[10][10] = { {0} };
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cin >> arr1[i][j];
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cin >> arr2[i][j];
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if (arr1[i][j] == arr2[i][j])
{
count++;
}
}
}
if (count == m * n)
{
cout << "Yes";
}
else
{
cout << "No";
}
return 0;
}