#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return a > b ? a : b; }
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> line(n), column(m);
  for (long long i = 0; i < n; i++) cin >> line[i];
  for (long long i = 0; i < m; i++) cin >> column[i];
  long long cur = 0;
  for (long long v : line) cur ^= v;
  for (long long v : column) cur ^= v;
  if (cur) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  long long kek = line[0];
  for (long long i = 1; i < m; i++) kek ^= column[i];
  cout << kek << ' ';
  for (long long i = 1; i < m; i++) cout << column[i] << ' ';
  cout << endl;
  for (long long i = 1; i < n; i++) {
    cout << line[i] << ' ';
    for (long long j = 1; j < m; j++) cout << 0 << ' ';
  }
}
