#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, siz = 1e2 + 5;
long long t, n, m, k, row[siz], col[siz], a[siz][siz];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  long long xor_r = 0, xor_c = 0;
  for (long long i = 1; i <= n; i++) cin >> row[i], xor_r ^= row[i];
  for (long long i = 1; i <= m; i++) cin >> col[i], xor_c ^= col[i];
  if (xor_c != xor_r) return cout << "NO\n", 0;
  cout << "YES\n";
  long long h = 0;
  for (long long i = m; i > 1; i--) h ^= col[i];
  a[1][1] = row[1] ^ h;
  for (long long i = 2; i <= n; i++) a[i][1] = row[i];
  for (long long i = 2; i <= m; i++) a[1][i] = col[i];
  for (long long i = 1; i <= n; i++, cout << endl)
    for (long long j = 1; j <= m; j++) cout << a[i][j] << " ";
}
