#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
int n, m;
int a[N], b[N];
int ra[N], rb[N];
int ans[N][N];
vector<int> r, c;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(time(NULL));
  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 k = 30; k >= 0; k--) {
    r.clear();
    c.clear();
    for (int i = 1; i <= m; i++)
      if (((a[i] >> (k)) & 1LL)) r.push_back(i);
    for (int j = 1; j <= n; j++)
      if (((b[j] >> (k)) & 1LL)) c.push_back(j);
    if ((int(r.size()) + int(c.size())) % 2) {
      cout << "NO\n";
      return 0;
    }
    for (int i = 0; i < min(int(r.size()), int(c.size())); i++) {
      ans[r[i]][c[i]] += (1LL << k);
    }
    if (int(r.size()) < int(c.size())) {
      for (int i = int(r.size()); i <= int(c.size()) - 1; i++) {
        ans[1][c[i]] += (1LL << k);
      }
    } else if (int(r.size()) > int(c.size())) {
      for (int i = int(c.size()); i <= int(r.size()) - 1; i++) {
        ans[r[i]][1] += (1LL << k);
      }
    }
  }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      ra[i] ^= ans[i][j];
      rb[j] ^= ans[i][j];
    }
  cout << "YES\n";
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) cout << ans[i][j] << " \n"[j == n];
}
