#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int n, m;
int a[101], b[101];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  int sum1 = 0, sum2 = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i == 1)
      sum1 = a[i];
    else
      sum1 = a[i] ^ sum1;
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    if (i == 1)
      sum2 = b[i];
    else
      sum2 = b[i] ^ sum2;
  }
  if (sum1 != sum2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (i != n && j != m) {
          cout << "0"
               << " ";
        } else if (i == n && j != m) {
          cout << b[j] << " ";
        } else if (j == m && i != n) {
          cout << a[i] << " ";
        } else if (j == m && i == n) {
          int x = a[n];
          for (int k = 1; k <= m - 1; k++) {
            x = x ^ b[k];
          }
          cout << x << " ";
        }
      }
      cout << endl;
    }
  }
  return 0;
}
