#include <bits/stdc++.h>
using namespace std;
int n, m;
long long a[110], b[110];
long long ans[110][110], sum;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    sum ^= a[i];
  }
  for (int i = 1; i <= m; i++) {
    scanf("%I64d", &b[i]);
    sum ^= b[i];
  }
  if (sum) {
    printf("NO");
    return 0;
  }
  for (int i = 1; i <= n - 1; i++) {
    ans[i][1] = a[i];
    b[1] ^= a[i];
  }
  for (int i = 1; i <= m; i++) ans[n][i] = b[i];
  printf("YES\n");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%I64d ", ans[i][j]);
    puts("");
  }
}
