#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
int a[MAXN], b[MAXN], suma, sumb;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    suma ^= a[i];
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    sumb ^= b[i];
  }
  if (suma != sumb) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n - 1; i++)
    for (int j = 1; j <= m; j++)
      if (j == m)
        printf("%d\n", a[i]);
      else
        printf("0 ");
  for (int i = 1; i <= m; i++)
    if (i == m)
      printf("%d", b[i] ^ suma ^ a[n]);
    else
      printf("%d ", b[i]);
}
