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