#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, grid[N][N];
int val[N][N];
bool vis[105][105];
int a[105];
int b[105];
int dp[105][105];
int tot;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", a + i), tot ^= a[i];
  int tmp = 0;
  for (int i = 0; i < m; i++) scanf("%d", b + i), tmp ^= b[i];
  if (tot != tmp) return puts("NO");
  for (int x = 0; x < 31; x++) {
    for (int i = 0; i < n; i++) {
      if (a[i] >> x & 1) {
        bool f = false;
        for (int j = 0; j < m; j++)
          if (b[j] >> x & 1) {
            grid[i][j] ^= (1 << x);
            b[j] ^= (1 << x);
            a[i] ^= (1 << x);
            break;
          }
      }
    }
    int cnt = 0;
    for (int j = 0; j < m; j++) cnt += (b[j] >> x & 1);
    if (cnt & 1) return puts("NO");
    for (int j = 0; j < m; j++)
      if (b[j] >> x & 1) grid[0][j] ^= (1 << x), b[j] ^= (1 << x);
  }
  for (int x = 0; x < 31; x++) {
    for (int j = 0; j < m; j++) {
      if (b[j] >> x & 1) {
        bool f = false;
        for (int i = 0; i < n; i++)
          if (a[i] >> x & 1) {
            grid[i][j] ^= (1 << x);
            b[j] ^= (1 << x);
            a[i] ^= (1 << x);
            break;
          }
      }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) cnt += (a[i] >> x & 1);
    if (cnt & 1) return puts("NO");
    for (int i = 0; i < n; i++)
      if (a[i] >> x & 1) grid[i][0] ^= (1 << x), a[i] ^= (1 << x);
  }
  puts("YES");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << grid[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
