#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> rows(n), cols(m);
  int sumR = 0, sumC = 0;
  for (int i = 0; i < n; ++i) {
    cin >> rows[i];
    sumR ^= rows[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> cols[i];
    sumC ^= cols[i];
  }
  if (sumR != sumC) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  cout << (rows[0] ^ sumC ^ cols[0]) << ' ';
  for (int j = 1; j < m; ++j) {
    cout << cols[j] << ' ';
  }
  cout << '\n';
  for (int i = 1; i < n; ++i) {
    cout << rows[i] << ' ';
    for (int j = 1; j < m; ++j) {
      cout << "0 ";
    }
    cout << '\n';
  }
  return 0;
}
