#include <bits/stdc++.h>
using namespace std;
int a[110], b[110];
int main() {
  int n, m;
  cin >> n >> m;
  int x = 0, y = 0;
  for (int i = 1; i <= n; i++) cin >> a[i], x ^= a[i];
  for (int i = 1; i <= m; i++) cin >> b[i], y ^= b[i];
  if (x == y) {
    puts("YES");
    int val = b[1];
    for (int i = 2; i <= n; i++) val ^= a[i];
    b[1] = val;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (i == 1)
          printf("%d ", b[j]);
        else if (j == 1)
          printf("%d ", a[i]);
        else
          printf("0 ");
      }
      printf("\n");
    }
    return 0;
  }
  puts("NO");
}
