#include <bits/stdc++.h>
using namespace std;
const int N = 102;
int n, m, a[N], b[N];
int d[N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> m >> n;
  for (int i(1); i <= m; i++) cin >> a[i];
  for (int i(1); i <= n; i++) cin >> b[i];
  for (int j = 2; j <= n; j++) {
    d[m][j] = b[j];
  }
  int x = 0;
  for (int i(1); i <= m - 1; i++) {
    d[i][1] = a[i];
    x ^= a[i];
  }
  x = b[1] ^ x;
  d[m][1] = x;
  for (int i(1); i <= m; i++) {
    x = 0;
    for (int j(1); j <= n; j++) x ^= d[i][j];
    if (x != a[i]) {
      cout << "NO";
      return 0;
    }
  }
  for (int j(1); j <= n; j++) {
    x = 0;
    for (int i(1); i <= m; i++) x ^= d[i][j];
    if (x != b[j]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES" << endl;
  for (int i(1); i <= m; i++) {
    for (int j(1); j <= n; j++) cout << d[i][j] << " ";
    cout << endl;
  }
}
