#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[105], b[105];
int c[105][105];
int main() {
  scanf("%d%d", &n, &m);
  int sum1 = 0;
  int sum2 = 0;
  for (int i = 1; i <= n; i++) {
    int k;
    scanf("%d", &k);
    a[i] = k;
    sum1 ^= k;
  }
  for (int i = 1; i <= m; i++) {
    int k;
    scanf("%d", &k);
    b[i] = k;
    sum2 ^= k;
  }
  if (sum1 != sum2) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  for (int i = 1; i <= n - 1; i++) {
    c[i][m] = a[i];
  }
  int sum = 0;
  for (int i = 1; i <= m - 1; i++) {
    c[n][i] = b[i];
    sum ^= b[i];
  }
  c[n][m] = a[n] ^ sum;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", c[i][j]);
    }
    printf("\n");
  }
  return 0;
}
