6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

//package Contest501div2;

import java.util.Scanner;

public class main501D {
    public static Scanner enter = new Scanner(System.in);
    public static void main(String[] args) {
        int n=enter.nextInt();
        int m=enter.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        int[][] mass= new int[n][m];
        int summ=0;
        int tmp=0;
        for (int i = 0; i <n ; i++) {
            a[i]=enter.nextInt();
            tmp^=a[i];
        }
        summ^=a[0];
        for (int i = 0; i <m ; i++) {
            b[i]=enter.nextInt();
            tmp^=b[i];
            summ^=b[i];
        }
        summ^=b[0];
        if(tmp!=0){
            System.out.println("NO");
        }
        else {
            System.out.println("YES");
            mass[0][0] = summ;
            for (int i = 1; i < m; i++) {
                mass[0][i] = b[i];
            }
            for (int i = 1; i < n; i++) {
                mass[i][0] = a[i];
            }

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    System.out.print(mass[i][j] + " ");
                }
                System.out.println();
            }
        }
    }
}
