#include <bits/stdc++.h>
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << " = " << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << " = " << h << ", ";
  _dbg(sdbg + 1, a...);
}
const int maxn = (1e6) + 7;
const int maxk = 20;
const int inf = (1e9) + 7;
const long long LLinf = (1e18) + 7;
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
int a[maxn], b[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int xo = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    xo ^= a[i];
  }
  int xd = xo;
  for (int j = 1; j <= m; j++) {
    cin >> b[j];
    xo ^= b[j];
  }
  xd ^= a[n] ^ b[m];
  if (xo != 0) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (i < n && j < m)
        cout << "0 ";
      else {
        if (i == n && j < m) {
          cout << b[j] << " ";
        } else {
          if (j == m && i < n) {
            cout << a[i] << " ";
          } else {
            cout << xd << " ";
          }
        }
      }
    }
    cout << "\n";
  }
  return 0;
}
