#include <bits/stdc++.h>
using namespace std;
int gr[110][110];
int main() {
  int n, m, a[110], b[100];
  cin >> n >> m;
  int nn = 0;
  int mm = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    nn ^= a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    mm ^= b[i];
  }
  if (nn != mm) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  memset(gr, 0, sizeof gr);
  for (int i = 0; i < n; i++) {
    gr[i][m - 1] = a[i];
  }
  for (int j = 0; j < m; j++) {
    gr[n - 1][j] = b[j];
  }
  gr[n - 1][m - 1] = mm ^ b[m - 1] ^ a[n - 1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%d ", gr[i][j]);
    }
    printf("\n");
  }
  return 0;
}
