#include <bits/stdc++.h>
using namespace std;
long long int arr[105][105];
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int r[n], c[m], tr1 = 0, tr2 = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> r[i];
    tr1 ^= r[i];
  }
  for (long long int i = 0; i < m; i++) {
    cin >> c[i];
    tr2 ^= c[i];
  }
  if (tr1 != tr2) {
    cout << "NO";
    exit(0);
  }
  for (long long int i = 1; i < n - 1; i++) arr[i][0] = r[i];
  for (long long int i = 1; i < m - 1; i++) arr[0][i] = c[i];
  arr[0][m - 1] = r[0] ^ c[0] ^ c[m - 1] ^ tr1;
  arr[n - 1][0] = r[0] ^ r[n - 1] ^ c[0] ^ tr1;
  arr[n - 1][m - 1] = arr[0][m - 1] ^ c[m - 1];
  cout << "YES" << endl;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) cout << arr[i][j] << " ";
    cout << endl;
  }
}
