#include <bits/stdc++.h>
using namespace std;
int n, m;
int A[103], B[103];
int C[103][103];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &B[i]);
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++) C[i][j] = 0;
  int xora = 0, xorb = 0;
  for (int i = 1; i < n; i++) C[i][m] = A[i], xora ^= A[i];
  for (int i = 1; i < m; i++) C[n][i] = B[i], xorb ^= B[i];
  if ((xora ^ B[m]) == (xorb ^ A[n])) {
    printf("YES\n");
    C[n][m] = xora ^ B[m];
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        printf("%d", C[i][j]);
        if (j < m) printf(" ");
      }
      printf("\n");
    }
  } else {
    printf("NO\n");
  }
}
