#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 6;
long long n, m;
long long co[maxn], ha[maxn];
long long c[200][200];
int main() {
  long long a;
  cin >> n >> m;
  long long num = 0, num1 = 0;
  for (int i = 1; i <= n; i++) {
    cin >> ha[i];
    num ^= ha[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> co[i];
    num1 ^= co[i];
  }
  if (num != num1) {
    cout << "NO" << endl;
    return 0;
  } else
    cout << "YES" << endl;
  num ^= ha[1];
  num ^= co[1];
  c[1][1] = num;
  for (int i = 2; i <= n; i++) {
    c[i][1] = ha[i];
  }
  for (int i = 2; i <= m; i++) {
    c[1][i] ^= co[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << c[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
  return 0;
}
