#include<stdio.h>
int main()
{
    int l = 0;
    int arr[40][40] = { 0 };
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < 2*n; i++)
    {
        for (int p = 0; p < m; p++)
        {
            scanf("%d",&arr[i][p]);
        }
    }
    for (int a = 0; a < n; a++)
    {
        for (int b = 0; b < m; b++)
        {
            if (arr[a][b] == arr[a + n][b])
                l++;
            //else
            //    break;
        }
    }
    if (l == n * m)
            printf("Yes\n");
    else
            printf("No\n");
    return 0;
}