#include <bits/stdc++.h>
using namespace std;
const int N = 300500;
const int mod = 1e9 + 7;
const long long inf = 1e18;
long long n, m, q;
long long a[N], b[N];
int res[303][303];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= m; ++i) cin >> b[i];
  int t = 0;
  for (int i = 1; i < n; ++i) res[i][1] = a[i], t ^= a[i];
  res[n][1] = t ^ b[1];
  int pre = res[1][n];
  for (int i = 2; i <= m; ++i) {
    res[n][i] = b[i] ^ pre;
  }
  for (int i = 1; i <= n; ++i) {
    int v = 0;
    for (int j = 1; j <= m; ++j) v ^= res[i][j];
    if (v != a[i]) return cout << "NO", 0;
  }
  for (int j = 1; j <= m; ++j) {
    int v = 0;
    for (int i = 1; i <= n; ++i) v ^= res[i][j];
    if (v != b[j]) return cout << "NO", 0;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) cout << res[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
