#include <bits/stdc++.h>
using namespace std;
int a[1005], b[1005];
int ans[1005][1005];
int main() {
  int n, m;
  cin >> n >> m;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x = x ^ a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    y = y ^ b[i];
  }
  if (x == y) {
    printf("YES\n");
    ans[0][0] = x ^ a[0] ^ b[0];
    for (int i = 1; i < m; i++) ans[0][i] = b[i];
    for (int i = 01; i < n; i++) ans[i][0] = a[i];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        printf("%d%c", ans[i][j], j == m - 1 ? '\n' : ' ');
      }
    }
  } else {
    printf("NO\n");
  }
  return 0;
}
