#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t1;
  t1 = 1;
  while (t1--) {
    long long m, n;
    cin >> m >> n;
    long long a[m], b[n];
    long long k1 = 0, k2 = 0;
    for (long long i = 0; i < m; i++) cin >> a[i], k1 ^= a[i];
    for (long long i = 0; i < n; i++) cin >> b[i], k2 ^= b[i];
    if (k1 != k2)
      cout << "NO";
    else {
      cout << "YES" << endl;
      long long dp[m][n];
      memset(dp, 0, sizeof(dp));
      long long k3 = 0;
      for (long long i = 1; i < n; i++) k3 ^= b[i];
      k3 ^= a[0];
      dp[0][0] = k3;
      for (long long i = 1; i < m; i++) dp[i][0] = a[i];
      for (long long j = 1; j < n; j++) dp[0][j] = b[j];
      for (long long i = 0; i < m; i++) {
        for (long long j = 0; j < n; j++) {
          cout << dp[i][j] << " ";
        }
        cout << endl;
      }
    }
  }
}
