#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long a[n], b[m];
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) cin >> b[i];
  long long arr[n][m];
  memset(arr, 0, sizeof(arr[0][0]) * n * m);
  long long row = 0, column = 0;
  for (int i = 0; i < n; ++i) {
    if (i != n - 1) {
      arr[i][m - 1] = a[i];
      row ^= a[i];
    } else
      arr[i][m - 1] = row ^ b[m - 1];
  }
  for (int i = 0; i < m - 1; ++i) {
    arr[n - 1][i] = b[i];
    column ^= b[i];
  }
  if ((column ^ arr[n - 1][m - 1]) == a[n - 1]) {
    cout << "YES" << endl;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        cout << arr[i][j] << " ";
      }
      cout << endl;
    }
  } else
    cout << "NO";
}
