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