#include <bits/stdc++.h>
using namespace std;
int T[105][105], R[105], C[105];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> R[i];
  for (int i = 0; i < m; i++) cin >> C[i];
  int x1 = 0, x2 = 0;
  for (int i = 0; i < n - 1; i++) T[i][m - 1] = R[i], x1 ^= R[i];
  for (int i = 0; i < m - 1; i++) T[n - 1][i] = C[i], x2 ^= C[i];
  if ((x1 ^ C[m - 1]) == (x2 ^ R[n - 1])) {
    cout << "YES\n";
    T[n - 1][m - 1] = (x1 ^ C[m - 1]);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) cout << T[i][j] << " ";
      cout << "\n";
    }
  } else {
    cout << "NO\n";
  }
  return 0;
}
