#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
int n, m;
long long a[N], b[N];
long long ans[N][N];
long long sum1, sum2, sum;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), sum1 ^= a[i];
  for (int i = 1; i <= m; i++) scanf("%lld", &b[i]), sum2 ^= b[i];
  if (sum1 != sum2) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 1; i < m; i++) sum ^= i;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < m; j++) ans[i][j] = j;
    ans[i][m] = a[i] ^ sum;
  }
  for (int j = 1; j <= m; j++) {
    long long tmp = 0;
    for (int i = 1; i < n; i++) tmp ^= ans[i][j];
    ans[n][j] = tmp ^ b[j];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%lld ", ans[i][j]);
    puts("");
  }
}
