#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[111];
int b[111];
int main() {
  cin >> n >> m;
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s ^= a[i];
  }
  int tmp = 0;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    tmp ^= b[i];
  }
  if (tmp != s) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i == 0 && j == 0) {
        cout << (tmp ^ a[0] ^ b[0]) << ' ';
      } else if (i == 0) {
        cout << b[j] << ' ';
      } else if (j == 0) {
        cout << a[i] << ' ';
      } else {
        cout << 0 << ' ';
      }
    }
    cout << endl;
  }
  return 0;
}
