#include <bits/stdc++.h>
using namespace std;
long long a[110], b[110], res[110][110];
int main() {
  long long n, m, i, x, y, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  x = 0;
  for (i = 1; i < n; i++) {
    res[i][0] = a[i];
    x ^= a[i];
  }
  res[0][0] = b[0] ^ x;
  y = 0;
  for (i = 1; i < m; i++) {
    res[0][i] = b[i];
    y ^= b[i];
  }
  if ((y ^ a[0]) != res[0][0]) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cout << res[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
