#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, n, m, a[305], b[205], c[2005][2003], x, y;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    l = l ^ a[i];
  }
  for (i = 1; i <= m; i++) {
    cin >> b[i];
    k = k ^ b[i];
  }
  if (l != k) {
    cout << "NO";
    exit(0);
  }
  for (i = 1; i < m; i++) c[n][i] = b[i];
  for (i = 1; i < n; i++) c[i][m] = a[i];
  l = l ^ a[n];
  k = k ^ b[m];
  c[n][m] = k ^ a[n];
  cout << "YES" << endl;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) cout << c[i][j] << ' ';
    cout << endl;
  }
}
