#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  int* r = new int[n];
  int* c = new int[m];
  int xor_row = 0, xor_col = 0;
  for (int i = 0; i != n; ++i) {
    std::cin >> r[i];
    xor_row ^= r[i];
  }
  for (int j = 0; j != m; ++j) {
    std::cin >> c[j];
    xor_col ^= c[j];
  }
  if (xor_row != xor_col) {
    std::cout << "NO" << std::endl;
    return 0;
  }
  std::cout << "YES" << std::endl;
  for (int i = 0; i != n - 1; ++i) {
    for (int j = 0; j != m - 1; ++j) {
      std::cout << 0 << " ";
    }
    std::cout << r[i] << std::endl;
  }
  for (int j = 0; j != m - 1; ++j) {
    std::cout << c[j] << " ";
  }
  std::cout << (r[n - 1] ^ c[m - 1] ^ xor_row) << std::endl;
  delete[] r;
  delete[] c;
}
