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