#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(vector<T> &v) {
  for (auto &a : v) cin >> a;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> r(n), c(m);
  read(r);
  read(c);
  int xs = 0;
  for (auto e : r) xs = xs ^ e;
  for (auto e : c) xs = xs ^ e;
  if (xs != 0) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    for (int i = 0; i < n - 1; i++) {
      for (int j = 0; j < m - 1; j++) cout << 0 << " ";
      cout << r[i] << endl;
    }
    for (int j = 0; j < m; j++) {
      xs = xs ^ (j == m - 1 ? r[n - 1] : c[j]);
      if (j == m - 1)
        cout << xs << endl;
      else
        cout << c[j] << " ";
    }
  }
  return 0;
}
