#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int x[10][10], y[10][10];
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++)
            cin >> x[i][j];
    }
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++)
            cin >> y[i][j];
    }
    for (int i = 0; i <= a; i++) {
        if (i == a) {
            cout << "Yes";
            break;
        }
        for (int j = 0; j < b; j++) {
            if (x[i][j] != y[i][j]) {
                cout << "No";
                return 0;
            }
        }
    }
    return 0;
}