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