#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int n, m, a, b, x, y, ans[maxn][maxn];
int main() {
  cin >> n >> m;
  for (int i = 0, k; i < n; ++i) {
    cin >> k;
    if (!i)
      x = k;
    else
      ans[i][0] = k;
    a ^= k;
  }
  for (int i = 0, k; i < m; ++i) {
    cin >> k;
    if (!i)
      y = k;
    else
      ans[0][i] = k;
    b ^= k;
  }
  if (a != b) return cout << "NO\n", 0;
  cout << "YES\n";
  ans[0][0] = a ^ x ^ y;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) cout << ans[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
