#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100 + 10;
int a[MAX_N], b[MAX_N];
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  string s = "";
  for (int i = 0; i < n - 1; i++) b[m - 1] ^= a[i];
  for (int i = 0; i < m - 1; i++) s += "0 ", a[n - 1] ^= b[i];
  if (b[m - 1] ^ a[n - 1])
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 0; i < n - 1; i++) cout << s << a[i] << endl;
    for (int i = 0; i < m; i++) cout << b[i] << ' ';
  }
  return 0;
}
