#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Edge
{
public:
    int to, cap, rev;
    Edge(){};
    Edge(int to0, int cap0){to = to0; cap = cap0;}
    Edge(int to0, int cap0, int rev0){to = to0; cap = cap0; rev = rev0;}
};

int maxFlow(const vector<vector<Edge> >& edges0, int source, int sink, vector<vector<Edge> >& edgesOut)
{
    static vector<vector<Edge> > edges;
    static vector<unsigned> index;
    static vector<int> level;
    static int n;

    class Func{
    public:
        static void bfs(int s){
            level.assign(n, -1);
            queue<int> q;
            level[s] = 0;
            q.push(s);
            while(!q.empty()){
                int v = q.front();
                q.pop();
                for(unsigned i=0; i<edges[v].size(); ++i){
                    Edge& e = edges[v][i];
                    if(e.cap > 0 && level[e.to] < 0){
                        level[e.to] = level[v] + 1;
                        q.push(e.to);
                    }
                }
            }
        }
        static int dfs(int s, int t, int f){
            if(s == t)
                return f;
            for(unsigned& i=index[s]; i<edges[s].size(); ++i){
                Edge& e = edges[s][i];
                if(e.cap > 0 && level[s] < level[e.to]){
                    int g = dfs(e.to, t, min(f, e.cap));
                    if(g > 0){
                        e.cap -= g;
                        edges[e.to][e.rev].cap += g;
                        return g;
                    }
                }
            }
            return 0;
        }
    };

    if(source == sink)
        return INT_MAX;

    n = edges0.size();
    edges.assign(n, vector<Edge>());
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges0[i].size(); ++j){
            const Edge& e = edges0[i][j];
            edges[i].push_back(Edge(e.to, e.cap, edges[e.to].size()));
            edges[e.to].push_back(Edge(i, 0, edges[i].size()-1));
        }
    }

    int ret = 0;
    for(;;){
        Func::bfs(source);
        if(level[sink] < 0){
            edgesOut.swap(edges);
            return ret;
        }
        index.assign(n, 0);
        int f;
        while((f = Func::dfs(source, sink, INT_MAX)) > 0)
            ret += f;
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> a, b;
    int aSum = 0;
    int bSum = 0;
    for(int i=0; i<=n; ++i){
        int x;
        cin >> x;
        while(--x >= 0){
            b.push_back(i);
            bSum += i;
        }
    }
    for(int i=0; i<=n; ++i){
        int x;
        cin >> x;
        while(--x >= 0){
            a.push_back(i);
            aSum += i;
        }
    }
    if(a.size() != n || b.size() != n || aSum != bSum){
        cout << "NO" << endl;
        return 0;
    }

    vector<vector<Edge> > edges(2*n+2);
    int source = 2 * n;
    int sink = 2 * n + 1;
    for(int i=0; i<n; ++i){
        edges[source].push_back(Edge(i, a[i]));
        edges[n+i].push_back(Edge(sink, b[i]));
        for(int j=0; j<n; ++j){
            edges[i].push_back(Edge(n+j, 1));
        }
    }

    vector<vector<Edge> > edges2;
    if(maxFlow(edges, source, sink, edges2) != aSum){
        cout << "NO" << endl;
        return 0;
    }

    vector<vector<int> > ans(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        for(const Edge& e : edges2[i]){
            if(n <= e.to && e.to < 2 * n && e.cap == 0){
                ans[i][e.to-n] = 1;
            }
        }
    }
    cout << "YES" << endl;
    for(int i=0; i<n; ++i){
        cout << ans[i][0];
        for(int j=1; j<n; ++j)
            cout << ' ' << ans[i][j];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3280