#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const double eps = 1e-9;
int n, m;
int a[maxn];
int b[maxn];
int ans[maxn][maxn];
int main() {
  scanf("%d%d", &n, &m);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum ^= a[i];
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    sum ^= b[i];
  }
  if (sum) return puts("NO"), 0;
  ans[0][0] = b[0];
  for (int i = 1; i < n; i++) ans[0][0] ^= a[i];
  for (int i = 1; i < m; i++) ans[0][i] = b[i];
  for (int i = 1; i < n; i++) ans[i][0] = a[i];
  int tmp = 0;
  for (int i = 0; i < m; i++) tmp ^= ans[0][i];
  if (tmp != a[0]) return puts("NO"), 0;
  puts("YES");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) printf("%d ", ans[i][j]);
    puts("");
  }
}
