#include <bits/stdc++.h>
using namespace std;
int n, m;
int ar[110][110];
vector<int> rws, cls;
int main() {
  scanf("%d%d", &n, &m);
  int row_xor = 0;
  int col_xor = 0;
  int yagitulah = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    rws.push_back(a);
    row_xor ^= a;
  }
  for (int j = 0; j < m; j++) {
    int a;
    scanf("%d", &a);
    cls.push_back(a);
    col_xor ^= a;
    if (j != 0) yagitulah ^= a;
  }
  if (col_xor != row_xor) {
    printf("NO\n");
  } else {
    printf("YES\n");
    memset(ar, 0, sizeof(ar));
    ar[0][0] = rws[0] ^= yagitulah;
    for (int i = 1; i < m; i++) {
      ar[0][i] = cls[i];
    }
    for (int i = 1; i < n; i++) {
      ar[i][0] = rws[i];
    }
    for (int i = 0; i < n; i++) {
      printf("%d", ar[i][0]);
      for (int j = 1; j < m; j++) {
        printf(" %d", ar[i][j]);
      }
      printf("\n");
    }
  }
}
