#include <bits/stdc++.h>
using namespace std;
const int maxn = 400;
int n, m;
int a[maxn][33], b[maxn][33], row[33], col[33];
long long c[maxn][maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    long long x;
    scanf("%lld", &x);
    for (long long j = 0; j < 33; j++)
      a[i][j] = (x >> j) & 1LL, row[j] ^= a[i][j];
  }
  for (int i = 0; i < m; i++) {
    long long x;
    scanf("%lld", &x);
    for (long long j = 0; j < 33; j++)
      b[i][j] = (x >> j) & 1LL, col[j] ^= b[i][j];
  }
  for (int i = 0; i < 33; i++)
    if (row[i] != col[i]) return !printf("NO\n");
  for (long long bit = 0; bit < 33; bit++) {
    for (int i = 0; i < n - 1; i++) {
      if (a[i][bit]) c[i][m - 1] ^= 1LL << bit;
    }
    for (int i = 0; i < m - 1; i++) {
      if (b[i][bit]) c[n - 1][i] ^= 1LL << bit;
    }
    long long cur = 0;
    for (int i = 0; i < m - 1; i++) cur ^= (c[n - 1][i] >> bit) & 1LL;
    if (cur != a[n - 1][bit]) c[n - 1][m - 1] ^= 1LL << bit;
  }
  puts("YES");
  for (int i = 0; i < n; i++, puts(""))
    for (int j = 0; j < m; j++) printf("%lld ", c[i][j]);
}
