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