import java.util.Scanner;
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] arr1 = new int[n][m];
        int[][] arr2 = new int[n][m];
        // arr1赋值
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                arr1[i][j] = sc.nextInt();
            }
        }
        // arr2赋值
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                arr2[i][j] = sc.nextInt();
            }
        }
        // 比较arr1和arr2
        int count = 0;
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                if(arr1[i][j] == arr2[i][j]) {
                    count++;
                }
            }
        }
        if(count == n*m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}