#include <bits/stdc++.h>
int r[102], c[102], n, m, a[102][102], R, C;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i++ < n; R ^= r[i]) scanf("%d", r + i);
  for (int i = 0; i++ < m; C ^= c[i]) scanf("%d", c + i);
  if (R ^ C) return puts("NO"), 0;
  for (int i = n; --i; a[i][m] = r[i])
    ;
  for (int i = m; --i; a[n][i] = c[i])
    ;
  a[n][m] = R ^ r[n] ^ c[m];
  puts("YES");
  for (int i = 0; i++ < n;)
    for (int j = 0; j++ < m; printf((j < m ? "%d " : "%d\n"), a[i][j]))
      ;
}
