#include <bits/stdc++.h>
using namespace std;
const long long N = 101;
const long long inf = 1e9;
long long n, m;
long long a[N], b[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(NULL));
  cin >> n >> m;
  long long res = 0;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    res ^= a[i];
  }
  for (long long i = 1; i <= m; ++i) {
    cin >> b[i];
    res ^= b[i];
  }
  if (res) return 0 * puts("NO");
  cout << "YES\n";
  for (long long i = 1; i < n; ++i) {
    for (long long j = 1; j < m; ++j) cout << "0 ";
    cout << a[i] << "\n";
    b[m] ^= a[i];
  }
  for (long long i = 1; i <= m; ++i) cout << b[i] << " ";
}
