#include <stdio.h>

int main() {
    int row = 0;
    int col = 0;
    while (scanf("%d %d", &row, &col) != EOF) 
    {
        int arr1[10][10] = {0};
        int arr2[10][10] = {0};
        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                scanf("%d", arr1[i] +j);
            }
        }

        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                scanf("%d", arr2[i] +j);
            }
        }

        int flag = 0;
        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                if (arr1[i][j] != arr2[i][j])
                {
                    flag++;
                }
            }
        }

        if (flag!=0)
        {
            printf("No\n");
        }
        else 
        {
            printf("Yes\n");
        }
        
    }
    return 0;
}