#include <bits/stdc++.h>
using namespace std;
int a[105];
int b[105];
int c[105][105] = {};
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  ;
  int odd = 0, even = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    odd ^= a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
    even ^= b[i];
  }
  if (odd != even) {
    puts("NO");
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    c[i][m - 1] = a[i];
  }
  int x = 0;
  for (int i = 0; i < m - 1; i++) {
    c[n - 1][i] = b[i];
    x ^= b[i];
  }
  c[n - 1][m - 1] = x ^ a[n - 1];
  puts("YES");
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      printf("%d%c", c[i][j], " \n"[j == m - 1]);
    }
}
