#include <bits/stdc++.h>
int a[10000];
int b[10000];
int ans[200][200];
int main() {
  int n, m;
  int i, j, x;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) scanf("%d", &b[i]);
  x = a[1];
  for (i = 1; i <= m - 1; i++) {
    ans[1][i] = b[i];
    x = x ^ b[i];
  }
  ans[1][m] = x;
  for (i = 2; i < n; i++) {
    x = x ^ a[i];
    ans[i][m] = a[i];
  }
  if ((x ^ b[m] ^ a[n]) == 0) {
    ans[n][m] = a[n];
  } else {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (i == 1 || j == m)
        printf("%d ", ans[i][j]);
      else
        printf("0 ");
      if (j == m) printf("\n");
    }
}
