#include <stdio.h> int main() { int m = 0, n = 0; int i = 0, j = 0; int sum = 0; int arr1[100][100] = { 0 }; int arr2[100][100] = { 0 }; scanf("%d %d", &n, &m); for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { scanf("%d", &arr1[i][j]); } } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { scanf("%d", &arr2[i][j]); } } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { if (arr1[i][j] == arr2[i][j]) { sum++; } } } if (sum == m * n) { printf("Yes\n"); } else printf("No\n"); return 0; }