#include <bits/stdc++.h>
using std::max;
using std::min;
using std::swap;
int n, m;
int a[105], b[105], c[105][105];
int getint() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
signed main() {
  n = getint(), m = getint();
  for (int i = 1; i <= n; i++) a[i] = getint();
  for (int i = 1; i <= m; i++) b[i] = getint();
  for (int i = 2; i <= n; i++) c[i][1] = a[i];
  for (int i = 2; i <= m; i++) c[1][i] = b[i];
  int xx = 0;
  for (int i = 2; i <= m; i++) xx ^= b[i];
  xx ^= a[1];
  c[1][1] = xx;
  xx = 0;
  for (int i = 1; i <= n; i++) xx ^= c[i][1];
  if (xx != b[1]) return printf("NO"), 0;
  printf("YES\n");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", c[i][j]);
    puts("");
  }
}
