#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n), b(m);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < m; ++i) cin >> b[i];
  long long tot = 0;
  for (long long i = 0; i < n; ++i) tot ^= a[i];
  for (long long i = 0; i < m; ++i) tot ^= b[i];
  if (tot == 0) {
    cout << "YES\n";
    for (long long i = 0; i < n - 1; ++i) {
      for (long long j = 0; j < m - 1; ++j) {
        cout << 0 << " ";
      }
      cout << a[i] << "\n";
    }
    long long last = a[n - 1];
    for (long long j = 0; j < m - 1; ++j) {
      cout << b[j] << " ";
      last ^= b[j];
    }
    cout << last << "\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
