#include <bits/stdc++.h>
using namespace std;
#define MAXN 204
int h[MAXN], e[MAXN];
int r[MAXN / 2], col[MAXN / 2];
int c[MAXN][MAXN], f[MAXN][MAXN], cf[MAXN][MAXN];
bool visit[MAXN];
vector<int> graph[MAXN];
void initializePreflow(int n, int s, int t)
{
memset(h, 0, (n + 1) * sizeof(int));
h[s] = n;
memset(e, 0, (n + 1) * sizeof(int));
int v;
for (int i = 0; i < graph[s].size(); i++) {
v = graph[s][i];
f[s][v] = c[s][v];
f[v][s] = -c[s][v];
e[v] = c[s][v];
e[s] -= c[s][v];
cf[s][v] = c[s][v] - f[s][v];
cf[v][s] = c[v][s] - f[v][s];
}
}
void push(int u, int v)
{
int temp = min(e[u], cf[u][v]);
f[u][v] += temp;
f[v][u] = -f[u][v];
e[u] -= temp;
e[v] += temp;
cf[u][v] = c[u][v] - f[u][v];
cf[v][u] = c[v][u] - f[v][u];
}
void maxflow(int n, int s, int t)
{
queue<int> q;
int u, v, m;
initializePreflow(n, s, t);
for (int i = 0; i < graph[s].size(); i++) {
if (graph[s][i] != t) {
q.push(graph[s][i]);
visit[graph[s][i]] = 1;
}
}
while (!q.empty()) {
u = q.front();
m = -1;
for (int i = 0; i < graph[u].size() && e[u] > 0; i++) {
v = graph[u][i];
if (cf[u][v] > 0) {
if (h[u] > h[v]) {
push(u, v);
if (!visit[v] && v != s && v != t) {
visit[v] = true;
q.push(v);
}
}
else if (m == -1)
m = h[v];
else
m = min(m, h[v]);
}
}
if (e[u] != 0)
h[u] = 1 + m;
else {
visit[u] = false;
q.pop();
}
}
}
int main()
{
int n, s, t;
int sr[MAXN / 2], sc[MAXN / 2];
int A[MAXN / 2][MAXN / 2];
scanf("%d", &n);
s = 0;
t = 2 * n + 1;
for (int i = 1; i <= n; i++)
scanf("%d", &sr[i]);
for (int i = 1; i <= n; i++)
scanf("%d", &sc[i]);
for (int i = 1; i <= n; i++) {
graph[s].push_back(i);
graph[i].push_back(s);
c[s][i] = sc[i];
cf[s][i] = c[s][i];
}
for (int i = n + 1; i <= 2 * n; i++) {
graph[i].push_back(t);
graph[t].push_back(i);
c[i][t] = sr[i - n];
cf[i][t] = c[i][t];
}
for (int i = 1; i <= n; i++) {
for (int j = n + 1; j <= 2 * n; j++) {
graph[i].push_back(j);
graph[j].push_back(i);
c[i][j] = 100;
cf[i][j] = c[i][j];
}
}
maxflow(n, s, t);
bool possible = true;
for (int i = 1; i <= n && possible; i++) {
for (int j = 1; j <= n && possible; j++) {
A[i][j] = f[j][i + n];
if (A[i][j] < 0 || A[i][j] > 100)
possible = false;
r[i] += A[i][j];
col[j] += A[i][j];
}
}
if (possible) {
for (int i = 1; i <= n; i++) {
if (sr[i] != r[i] || sc[i] != col[i])
possible = false;
}
}
if (possible) {
printf("YES\n");
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (j == 1)
printf("%d", A[i][j]);
else
printf(" %d", A[i][j]);
}
printf("\n");
}
}
else
printf("NO\n");
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBNQVhOIDIwNAoKaW50IGhbTUFYTl0sIGVbTUFYTl07CmludCByW01BWE4gLyAyXSwgY29sW01BWE4gLyAyXTsKaW50IGNbTUFYTl1bTUFYTl0sIGZbTUFYTl1bTUFYTl0sIGNmW01BWE5dW01BWE5dOwpib29sIHZpc2l0W01BWE5dOwp2ZWN0b3I8aW50PiBncmFwaFtNQVhOXTsKCnZvaWQgaW5pdGlhbGl6ZVByZWZsb3coaW50IG4sIGludCBzLCBpbnQgdCkKewogICAgbWVtc2V0KGgsIDAsIChuICsgMSkgKiBzaXplb2YoaW50KSk7CiAgICBoW3NdID0gbjsKICAgIG1lbXNldChlLCAwLCAobiArIDEpICogc2l6ZW9mKGludCkpOwogICAgaW50IHY7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IGdyYXBoW3NdLnNpemUoKTsgaSsrKSB7CiAgICAgICAgdiA9IGdyY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W2ldOwogICAgICAgICAgICBpZiAoY2ZbdV1bdl0gPiAwKSB7CiAgICAgICAgICAgICAgICBpZiAoaFt1XSA+IGhbdl0pIHsKICAgICAgICAgICAgICAgICAgICBwdXNoKHUsIHYpOwogICAgICAgICAgICAgICAgICAgIGlmICghdmlzaXRbdl0gJiYgdiAhPSBzICYmIHYgIT0gdCkgewogICAgICAgICAgICAgICAgICAgICAgICB2aXNpdFt2XSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHEucHVzaCh2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlIGlmIChtID09IC0xKQogICAgICAgICAgICAgICAgICAgIG0gPSBoW3ZdOwogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIG0gPSBtaW4obSwgaFt2XSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGVbdV0gIT0gMCkKICAgICAgICAgICAgaFt1XSA9IDEgKyBtOwogICAgICAgIGVsc2UgewogICAgICAgICAgICB2aXNpdFt1XSA9IGZhbHNlOwogICAgICAgICAgICBxLnBvcCgpOwogICAgICAgIH0KICAgIH0KfQoKaW50IG1haW4oKQp7CiAgICBpbnQgbiwgcywgdDsKICAgIGludCBzcltNQVhOIC8gMl0sIHNjW01BWE4gLyAyXTsKICAgIGludCBBW01BWE4gLyAyXVtNQVhOIC8gMl07CiAgICBzY2FuZigiJWQiLCAmbik7CiAgICBzID0gMDsKICAgIHQgPSAyICogbiArIDE7CgogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSAKICAgICAgICBzY2FuZigiJWQiLCAmc3JbaV0pOwoKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykKICAgICAgICBzY2FuZigiJWQiLCAmc2NbaV0pOwoKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgewogICAgICAgIGdyYXBoW3NdLnB1c2hfYmFjayhpKTsKICAgICAgICBncmFwaFtpXS5wdXNoX2JhY2socyk7CiAgICAgICAgY1tzXVtpXSA9IHNjW2ldOwogICAgICAgIGNmW3NdW2ldID0gY1tzXVtpXTsKICAgIH0KCiAgICBmb3IgKGludCBpID0gbiArIDE7IGkgPD0gMiAqIG47IGkrKykgewogICAgICAgIGdyYXBoW2ldLnB1c2hfYmFjayh0KTsKICAgICAgICBncmFwaFt0XS5wdXNoX2JhY2soaSk7CiAgICAgICAgY1tpXVt0XSA9IHNyW2kgLSBuXTsKICAgICAgICBjZltpXVt0XSA9IGNbaV1bdF07CiAgICB9CgogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IG4gKyAxOyBqIDw9IDIgKiBuOyBqKyspIHsKICAgICAgICAgICAgZ3JhcGhbaV0ucHVzaF9iYWNrKGopOwogICAgICAgICAgICBncmFwaFtqXS5wdXNoX2JhY2soaSk7CiAgICAgICAgICAgIGNbaV1bal0gPSAxMDA7CiAgICAgICAgICAgIGNmW2ldW2pdID0gY1tpXVtqXTsKICAgICAgICB9CiAgICB9CgogICAgbWF4ZmxvdyhuLCBzLCB0KTsKCiAgICBib29sIHBvc3NpYmxlID0gdHJ1ZTsKCiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuICYmIHBvc3NpYmxlOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMTsgaiA8PSBuICYmIHBvc3NpYmxlOyBqKyspIHsKICAgICAgICAgICAgQVtpXVtqXSA9IGZbal1baSArIG5dOwogICAgICAgICAgICBpZiAoQVtpXVtqXSA8IDAgfHwgQVtpXVtqXSA+IDEwMCkKICAgICAgICAgICAgICAgIHBvc3NpYmxlID0gZmFsc2U7CiAgICAgICAgICAgIHJbaV0gKz0gQVtpXVtqXTsKICAgICAgICAgICAgY29sW2pdICs9IEFbaV1bal07CiAgICAgICAgfQogICAgfQoKICAgIGlmIChwb3NzaWJsZSkgewogICAgICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgewogICAgICAgICAgICBpZiAoc3JbaV0gIT0gcltpXSB8fCBzY1tpXSAhPSBjb2xbaV0pCiAgICAgICAgICAgICAgICBwb3NzaWJsZSA9IGZhbHNlOwogICAgICAgIH0KICAgIH0KCiAgICBpZiAocG9zc2libGUpIHsKICAgICAgICBwcmludGYoIllFU1xuIik7CiAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSB7CiAgICAgICAgICAgIGZvciAoaW50IGogPSAxOyBqIDw9IG47IGorKykgewogICAgICAgICAgICAgICAgaWYgKGogPT0gMSkKICAgICAgICAgICAgICAgICAgICBwcmludGYoIiVkIiwgQVtpXVtqXSk7CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCIgJWQiLCBBW2ldW2pdKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwcmludGYoIlxuIik7CiAgICAgICAgfQogICAgfQogICAgZWxzZQogICAgICAgIHByaW50ZigiTk9cbiIpOwogICAgcmV0dXJuIDA7Cn0K