#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int a[105], b[105];
  int ss = 0, pp = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ss ^= a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    pp ^= b[i];
  }
  if (ss != pp) {
    printf("NO\n");
    return 0;
  } else {
    printf("YES\n");
  }
  int sum = a[n];
  for (int i = 1; i < m; i++) {
    sum ^= b[i];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      if (j == m) {
        printf("%d", a[i]);
      } else {
        printf("0 ");
      }
    }
    printf("\n");
  }
  for (int i = 1; i < m; i++) {
    printf("%d ", b[i]);
  }
  printf("%d\n", sum);
  return 0;
}
