#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(m);
  for (ll i = 0; i < (ll)n; i++) cin >> a[i];
  for (ll i = 0; i < (ll)m; i++) cin >> b[i];
  ll xor1 = 0, xor2 = 0;
  for (ll i = 0; i < (ll)n; i++) xor1 ^= a[i];
  for (ll i = 0; i < (ll)m; i++) xor2 ^= b[i];
  if (xor1 != xor2) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  vector<vector<ll>> ans(n, vector<ll>(m));
  for (ll i = 0; i < (ll)n - 1; i++) {
    ans[i][0] = a[i];
    b[0] ^= a[i];
  }
  for (ll i = 0; i < (ll)m; i++) ans[n - 1][i] = b[i];
  for (ll i = 0; i < (ll)n; i++)
    for (ll d = 0; d < (ll)ans[i].size(); d++) {
      cout << ans[i][d];
      if (d != ans[i].size() - 1)
        cout << " ";
      else
        cout << endl;
    };
  return 0;
}
