#include <bits/stdc++.h>
using namespace std;
ofstream outfile;
ifstream infile;
int main() {
  infile.open("input.txt");
  outfile.open("output.txt");
  int temp = 0, a[110], b[110];
  int i, j, n, m;
  cin >> n >> m;
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
    temp ^= a[i];
  }
  for (j = 1; j <= m; ++j) {
    cin >> b[j];
    temp ^= b[j];
  }
  if (temp == 0) {
    cout << "YES\n";
    int matrix[110][110];
    memset(matrix, 0, sizeof(matrix));
    ;
    for (i = 2; i <= m; ++i) {
      matrix[1][i] = b[i];
      temp ^= b[i];
    }
    matrix[1][1] = temp ^ a[1];
    for (i = 2; i <= n; ++i) {
      matrix[i][1] = a[i];
    }
    for (i = 1; i <= n; ++i) {
      for (j = 1; j <= m; ++j) cout << matrix[i][j] << ' ';
      cout << "\n";
    }
  } else {
    cout << "NO\n";
  }
}
