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