#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int arr[n];
  int arrr[m];
  int t = 0;
  int p = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    t = t ^ arr[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> arrr[i];
    p = p ^ arrr[i];
  }
  if (t == p) {
    cout << "YES" << endl;
    cout << ((p ^ arrr[0]) ^ arr[0]) << " ";
    for (int i = 1; i < m; i++) {
      if (i == m - 1) {
        cout << arrr[m - 1] << endl;
      } else {
        cout << arrr[i] << " ";
      }
    }
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (j == 0) {
          cout << arr[i] << " ";
        } else if (j == m - 1) {
          cout << 0 << endl;
        } else {
          cout << 0 << " ";
        }
      }
    }
  } else
    cout << "NO" << endl;
}
