#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int a[N], b[N], c[N][N];
int main() {
  int n, m, flag = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    flag ^= a[i];
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", b + i);
    flag ^= b[i];
  }
  if (flag)
    puts("NO");
  else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i] & b[j]) {
          c[i][j] = a[i] & b[j];
          a[i] ^= c[i][j];
          b[j] ^= c[i][j];
        } else
          c[i][j] = 0;
      }
      if (a[i]) {
        c[i][m - 1] ^= a[i];
        a[i] ^= a[i];
      }
    }
    for (int j = 0; j < m; j++) {
      for (int i = 0; i < n - 1; i++) {
        if (b[j] & a[i]) {
          c[i][j] = a[i] & b[j];
          a[i] ^= c[i][j];
          b[j] ^= c[i][j];
        }
      }
      if (b[j]) {
        c[n - 1][j] ^= b[j];
        a[n - 1] ^= b[j];
        b[j] ^= b[j];
      }
    }
    puts("YES");
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        printf("%d ", c[i][j]);
      }
      puts("");
    }
  }
  return 0;
}
