#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m;
int a[N];
int b[N];
int ans[N][N];
int main() {
  cin >> n >> m;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s ^= a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
    s ^= b[i];
  }
  if (s != 0) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  if (n > m) {
    for (int i = 0; i < m; ++i) ans[i][0] ^= a[i] ^ b[i];
    for (int i = m; i < n; ++i) ans[i][0] ^= a[i];
    for (int i = 0; i < m; ++i) ans[i][i] ^= b[i];
  } else {
    for (int i = 0; i < n; ++i) ans[0][i] ^= a[i] ^ b[i];
    for (int i = n; i < m; ++i) ans[0][i] ^= b[i];
    for (int i = 0; i < n; ++i) ans[i][i] ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}
