#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
long long a[maxn], b[maxn];
long long mat[maxn][maxn];
int main() {
  int n, m;
  ios::sync_with_stdio(false);
  cin >> n >> m;
  long long ans1 = 0, ans2 = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ans1 ^= a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    ans2 ^= b[i];
  }
  if (ans1 != ans2) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= m; j++) {
      mat[i][j] = 1;
    }
  }
  long long last = 0;
  for (int j = m; j >= 2; j--) {
    long long temp = 0;
    for (int i = n; i >= 2; i--) {
      temp ^= mat[i][j];
    }
    mat[1][j] = temp ^ b[j];
    last ^= mat[1][j];
  }
  for (int i = n; i >= 2; i--) {
    long long temp = 0;
    for (int j = m; j >= 2; j--) {
      temp ^= mat[i][j];
    }
    mat[i][1] = temp ^ a[i];
  }
  mat[1][1] = last ^ a[1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << mat[i][j] << " ";
    }
    cout << endl;
  }
}
