#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1005], b[1005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  int SumXor = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    SumXor = SumXor ^ a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    SumXor = SumXor ^ b[i];
  }
  if (SumXor != 0) {
    cout << "NO";
    return 0;
  }
  for (int i = 2; i <= m; i++) {
    SumXor = SumXor ^ b[i];
  }
  SumXor ^= a[1];
  cout << "YES\n";
  cout << SumXor << ' ';
  for (int i = 2; i <= m; i++) {
    cout << b[i] << ' ';
  }
  cout << '\n';
  for (int i = 2; i <= n; i++) {
    cout << a[i] << ' ';
    for (int j = 2; j <= m; j++) {
      cout << 0 << ' ';
    }
    cout << '\n';
  }
  return 0;
}
