#include <bits/stdc++.h>
using namespace std;
const int N = 111;
int n, m, a[N], b[N], mat[N][N];
int rows, cols;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i), rows ^= a[i];
  for (int j = 1; j <= m; j++) scanf("%d", b + j), cols ^= b[j];
  if (rows != cols) {
    printf("NO\n");
    return 0;
  }
  mat[1][1] = rows ^ a[1] ^ b[1];
  for (int i = 2; i <= n; i++) mat[i][1] = a[i];
  for (int j = 2; j <= m; j++) mat[1][j] = b[j];
  printf("YES\n");
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) printf("%d%c", mat[i][j], j == m ? '\n' : ' ');
  return 0;
}
