#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int maxn = 300010;
const int mod = 1000000;
const int inf = 0x3f3f3f3f;
const int INF = 0x7FFFFFFF;
void Mod(long long &x) { x %= mod; }
long long Min(long long a, long long b) { return a < b ? a : b; }
long long Max(long long a, long long b) { return a > b ? a : b; }
long long Abs(long long x) { return x >= 0 ? x : -x; }
int Random() {
  static int seed = 703;
  return seed = (int)(seed * 48271LL % 2147483647);
}
int n, m, a[110], b[110], ans[110][110];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) ans[i][j] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 30; j++) {
      int cnt = 0;
      for (int k = 1; k <= m; k++)
        if (b[k] & (1 << j)) cnt++;
      int obt = (a[i] & (1 << j)) ? 1 : 0;
      if (cnt == 0 && obt == 1)
        b[1] += (1 << j), ans[i][1] += (1 << j);
      else {
        if (obt == 0 && cnt % 2 == 1) cnt--;
        if (obt == 1 && cnt % 2 == 0) cnt--;
        for (int k = 1; k <= m; k++)
          if (b[k] & (1 << j) && cnt)
            b[k] -= (1 << j), cnt--, ans[i][k] += (1 << j);
      }
    }
  }
  int ok = 1;
  for (int i = 1; i <= m; i++)
    if (b[i] != 0) ok = 0;
  if (ok) {
    printf("YES\n");
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (j != 1) printf(" ");
        printf("%d", ans[i][j]);
      }
      printf("\n");
    }
  } else
    printf("NO\n");
  return 0;
}
