#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 55;
const long long mod = (1e9) + 7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template <class T>
T Max(T &a, T b) {
  return a = max(a, b);
}
template <class T>
T Min(T &a, T b) {
  return a = min(a, b);
}
long long n;
long long G[1000][1000], A[1000], B[1000], tmp[1000];
bool check() {
  long long in[1000] = {}, out[1000] = {};
  long long cnti[1000] = {}, cnto[1000] = {};
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) {
      out[i] += G[i][j];
      in[j] += G[i][j];
    }
  for (long long i = 0; i < n; i++) cnti[in[i]]++, cnto[out[i]]++;
  for (long long i = 0; i < n + 1; i++)
    if (A[i] != cnto[i] || B[i] != cnti[i]) return 0;
  return 1;
}
class Bridges {
  struct edgeB {
    long long u, v;
  };
  long long V;
  vector<long long> G[1000];
  vector<edgeB> bridges;
  long long ord[1000];
  long long low[1000];
  Bridges() { V = -1; }
  Bridges(long long V) { this->V = V; }
  void add_edge(long long a, long long b) {
    G[a].push_back(b);
    G[b].push_back(a);
  }
  void dfs(long long u, long long p, long long &c) {
    ord[u] = low[u] = c++;
    for (long long i = 0; i < G[u].size(); i++) {
      long long v = G[u][i];
      if (v == p) continue;
      if (ord[v] == -1) {
        dfs(v, u, c);
        low[u] = min(low[u], low[v]);
      } else
        low[u] = min(low[u], ord[v]);
      if (ord[u] < low[v]) bridges.push_back((edgeB){u, v});
    }
  }
  void bridge() {
    assert(V >= 0);
    bridges.clear();
    long long c = 0;
    memset(ord, -1, sizeof(ord));
    for (long long i = 0; i < V; i++)
      if (ord[i] == -1) dfs(i, -1, c);
  }
};
signed main() {
  cin >> n;
  for (long long i = 0; i < n + 1; i++) cin >> B[i], tmp[i] = B[i];
  for (long long i = 0; i < n + 1; i++) cin >> A[i];
  long long in[1000] = {};
  vector<long long> can(1000, 1);
  for (long long i = A[0], k = 1; k <= n; k++) {
    for (long long l = 0; l < A[k] && i < n; i++, l++) {
      long long cnt = 0;
      for (long long j = 0; j < n; j++) {
        if (cnt == k || can[j] == 0 || G[i][j]) continue;
        cout << "k=" << k << " " << cnt << " " << i << " " << j << endl;
        G[i][j] = 1;
        in[j]++;
        cnt++;
      }
      for (long long j = 0; j < n; j++)
        if (can[j] && B[in[j]]) B[in[j]]--, can[j] = 0;
    }
  }
  for (long long i = 0; i < n + 1; i++) B[i] = tmp[i];
  if (!check() && 0)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        if (j) cout << " ";
        cout << G[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}
