#include <bits/stdc++.h>
using namespace std;
int n, m;
long long int a[300105], b[300105];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  long long int xrow = 0, xcol = 0;
  for (int i = 0; i < n; ++i) cin >> a[i], xrow ^= a[i];
  for (int i = 0; i < m; ++i) cin >> b[i], xcol ^= b[i];
  if (xrow != xcol) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    for (int i = 0; i < n - 1; ++i) {
      for (int j = 0; j < m - 1; ++j) cout << "0 ";
      cout << a[i] << "\n";
    }
    for (int j = 0; j < m - 1; ++j) cout << b[j] << " ", a[n - 1] ^= b[j];
    cout << a[n - 1] << "\n";
  }
}
