#include <bits/stdc++.h>
using namespace std;
inline int read(int u = 0, char c = getchar(), bool f = false) {
  for (; !isdigit(c); c = getchar()) f |= c == '-';
  for (; isdigit(c); c = getchar()) u = u * 10 + c - '0';
  return f ? -u : u;
}
const int maxn = 100 + 10;
int a[maxn], b[maxn], c[maxn][maxn];
int main() {
  int 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 B = 0; B < 31; B++) {
    int n1 = 0, m1 = 0;
    for (int i = 1; i <= n; i++) n1 += (a[i] >> B & 1);
    for (int i = 1; i <= m; i++) m1 += (b[i] >> B & 1);
    if ((n1 ^ m1) & 1) {
      return 0 * puts("NO");
    }
    if (n1 & 1) {
      for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
          c[i][j] |= ((a[i] >> B & 1) & (b[j] >> B & 1)) << B;
    } else {
      for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
          c[i][j] |= ((a[i] >> B & 1) & (b[j] >> B & 1)) << B;
      int x = 0, y = 0;
      for (int i = 1; i <= n; i++)
        if (a[i] >> B & 1) x = i;
      for (int j = 1; j <= m; j++)
        if (b[j] >> B & 1) y = j;
      if (x && y) {
        for (int j = 1; j <= m; j++)
          if (b[j] >> B & 1) c[x][j] ^= 1 << B;
        for (int i = 1; i <= n; i++)
          if (a[i] >> B & 1) c[i][y] ^= 1 << B;
      } else if (x) {
        for (int i = 1; i <= n; i++)
          if (a[i] >> B & 1) c[i][1] |= 1 << B;
      } else if (y) {
        for (int j = 1; j <= m; j++)
          if (b[j] >> B & 1) c[1][j] |= 1 << B;
      }
    }
  }
  puts("YES");
  for (int i = 1; i <= n; i++, puts(""))
    for (int j = 1; j <= m; j++) printf("%d ", c[i][j]);
}
