#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  long long a[105];
  long long b[105];
  cin >> n >> m;
  long long t1 = 0, t2 = 0;
  for (int i = 1; i <= n; i++) cin >> a[i], t1 ^= a[i];
  for (int i = 1; i <= m; i++) cin >> b[i], t2 ^= b[i];
  if (t1 != t2)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (i == 1) {
          if (j == 1) {
            long long temp = a[1] ^ t2 ^ b[1];
            cout << temp << " ";
          } else
            cout << b[j] << " ";
        } else if (j == 1)
          cout << a[i] << " ";
        else
          cout << "0 ";
      }
      cout << endl;
    }
  }
  return 0;
}
