#include <bits/stdc++.h>
using namespace std;
int n, m;
int row[101], col[101];
int mat[101][101];
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    memset(mat, 0, sizeof(mat));
    int tmp = 0;
    for (int i = 1; i <= n; i++) cin >> row[i];
    for (int i = 1; i <= m; i++) cin >> col[i];
    for (int i = 2; i <= n; i++) tmp ^= row[i];
    for (int i = 1; i <= m; i++) tmp ^= col[i];
    if (tmp != row[1]) {
      cout << "NO" << endl;
      continue;
    } else {
      cout << "YES" << endl;
      int ind = 0;
      for (int i = 1; i < n; i++) {
        tmp = 0;
        for (int j = 1; j < m; j++) {
          mat[i][j] = ++ind;
          tmp ^= ind;
        }
        mat[i][m] = tmp ^ row[i];
      }
      for (int i = 1; i <= m; i++) {
        tmp = 0;
        for (int j = 1; j < n; j++) tmp ^= mat[j][i];
        mat[n][i] = tmp ^ col[i];
      }
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
          if (j != m)
            cout << mat[i][j] << " ";
          else
            cout << mat[i][j] << endl;
        }
      }
    }
  }
  return 0;
}
