#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 1e18;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
int n, m;
int a[105];
int b[105];
int main() {
  scanf("%d %d", &n, &m);
  int xa = 0, xb = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    xa ^= a[i];
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    xb ^= b[i];
  }
  if (xa != xb) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  xb ^= b[0] ^ a[0];
  printf("%d ", xb);
  for (int i = 1; i < m; i++) printf("%d ", b[i]);
  printf("\n");
  for (int i = 1; i < n; i++) {
    printf("%d ", a[i]);
    for (int j = 1; j < m; j++) printf("0 ");
    printf("\n");
  }
  return 0;
}
