#include <bits/stdc++.h>
namespace chtholly {
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) f ^= c == '-';
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ '0');
  return f ? x : -x;
}
template <typename mitsuha>
inline bool read(mitsuha &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c) && ~c; c = getchar()) f ^= c == '-';
  if (!~c) return 0;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ '0');
  return x = f ? x : -x, 1;
}
template <typename mitsuha>
inline int write(mitsuha x) {
  if (!x) return 0 & putchar(48);
  if (x < 0) x = -x, putchar('-');
  int bit[20], i, p = 0;
  for (; x; x /= 10) bit[++p] = x % 10;
  for (i = p; i; --i) putchar(bit[i] + 48);
  return 0;
}
inline char fuhao() {
  char c = getchar();
  for (; isspace(c); c = getchar())
    ;
  return c;
}
}  // namespace chtholly
using namespace chtholly;
using namespace std;
int n, m, a[105], b[105];
int ans[105][105];
void getans() {
  int i, j;
  for (i = 1; i < n; ++i) {
    for (j = 1; j < m; ++j) {
      ans[i][j] = 0;
    }
  }
  for (i = 1; i < n; ++i) ans[i][m] = a[i];
  for (i = 1; i < m; ++i) ans[n][i] = b[i];
  for (i = 1; i < n; ++i) b[m] ^= a[i];
  ans[n][m] = b[m];
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) a[i] = read();
  for (i = 1; i <= m; ++i) b[i] = read();
  int cnt1 = 0, cnt2 = 0;
  for (i = 1; i <= n; ++i) cnt1 ^= (a[i]);
  for (i = 1; i <= m; ++i) cnt2 ^= (b[i]);
  if (cnt1 ^ cnt2) return puts("NO"), 0;
  puts("YES");
  getans();
  for (i = 1; i <= n; ++i, puts("")) {
    for (j = 1; j <= m; ++j) write(ans[i][j]), putchar(' ');
  }
}
