import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[][] arr1 = new int[n][m];
        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j < arr1[i].length; j++) {
                arr1[i][j] = scan.nextInt();
            }
        }
        int[][] arr2 = new int[n][m];
        for (int i = 0; i < arr2.length; i++) {
            for (int j = 0; j < arr2[i].length; j++) {
                arr2[i][j] = scan.nextInt();
            }
        }
        
        int x = 0;
        for(int i = 0; i < n; i++) {
            if(Arrays.equals(arr1[i], arr2[i]) == false)
                x++;
        }
        
        if (x == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        //下面代码同样可以通过
//         if (arrayEquals(arr1, arr2)) {
//             System.out.println("Yes");
//         } else {
//             System.out.println("No");
//         }
    }
    //arrayEquals方法
    public static boolean arrayEquals(int[][] arr1, int[][] arr2) {
        if (arr1 == arr2) 
            return true;
        if (arr1 == null || arr2 == null) 
            return false;
        if (arr1.length != arr2.length) 
            return false;
        if (arr1[0].length != arr2[0].length)
            return false;
        
        for (int i = 0; i < arr1.length; i++) {
            if (Arrays.equals(arr1[i], arr2[i]) == false)
                return false;
        }
        return true;
    } 
}