#include <bits/stdc++.h>
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = true, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, m, g[101][101], a[101], b[101];
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = 1; i <= m; ++i) b[i] = read();
  for (int i = 0; i < 30; ++i) {
    for (int j = 1; j < n; ++j)
      for (int k = 1; k < m; ++k) g[j][k] |= 1 << i;
    int s1 = 0, s2 = 0;
    for (int j = 1; j < n; ++j)
      if (((m - 1) & 1) ^ ((bool)(a[j] & (1 << i)))) s1 ^= 1, g[j][m] |= 1 << i;
    for (int j = 1; j < m; ++j)
      if (((n - 1) & 1) ^ ((bool)(b[j] & (1 << i)))) s2 ^= 1, g[n][j] |= 1 << i;
    if ((((bool)(b[m] & (1 << i))) ^ s1) != (((bool)(a[n] & (1 << i))) ^ s2)) {
      puts("NO");
      exit(0);
    }
    if (((bool)(b[m] & (1 << i))) ^ s1) g[n][m] |= 1 << i;
  }
  puts("YES");
  for (int i = 1; i <= n; ++i, puts(""))
    for (int j = 1; j <= m; ++j) printf("%d ", g[i][j]);
  return 0;
}
