#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j;
  long col = 0, row = 0, a[102], b[102], last = 0;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    row ^= a[i];
  }
  for (j = 1; j <= m; j++) {
    cin >> b[j];
    col ^= b[j];
  }
  if (row != col) return cout << "NO\n", 0;
  cout << "YES\n";
  for (i = 1; i < n; i++) {
    for (j = 1; j < m; j++) cout << "0 ";
    cout << a[i] << endl;
    last ^= a[i];
  }
  for (j = 1; j < m; j++) cout << b[j] << " ";
  last ^= b[m];
  cout << last << endl;
  return 0;
}
