//from https://yukicoder.me/users/24897/ai_code/29 #include using namespace std; #ifdef _MSC_VER #include #endif using ll = long long; using ld = long double; using ull = unsigned long long; using P = pair; #define endl "\n" #define rep1(i,n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i,a,b) for (ll i = (ll)(a); i < (ll)(b); i++) #define OVERLOAD_REP(_1,_2,_3,name,...) name #define rep(...) OVERLOAD_REP(__VA_ARGS__, rep2, rep1)(__VA_ARGS__) #define rrep(i,n) for (ll i = (ll)(n) - 1; i >= 0; i--) #define all(s) (s).begin(), (s).end() #define fi first #define se second constexpr int MINT_MOD = 998244353; const ll mod = MINT_MOD; const ll inf = 4000000000000000000ll; const ld eps = ld(0.00000000001); static const long double pi = 3.141592653589793; constexpr ll MAX = 2000010; templatevoid vcin(vector &n){for(int i=0;i>n[i];} templatevoid vcin(vector &n,vector &m){for(int i=0;i>n[i]>>m[i];} templatevoid vcout(vector &n){for(int i=0;ivoid vcin(vector> &n){for(int i=0;i>n[i][j];}}} templatevoid vcout(vector> &n){for(int i=0;ivoid print(pair a){cout<auto min(const T& a){ return *min_element(all(a)); } templateauto max(const T& a){ return *max_element(all(a)); } templatebool chmax(T &a,const U b) { if (abool chmin(T &a,const U b) { if (b void ifmin(T t,T u){if(t>u){cout<<-1< void ifmax(T t,T u){if(t>u){cout<<-1< using V = vector; template using VV = V>; template using VVV = V>>; template auto mvec(T val, ll n) { return V(n, val); } template auto mvec(T val, ll n, Args... args) { return V(n, mvec(val, args...)); } vector divisor(ll x){ vector ans; for(ll i = 1; i * i <= x; i++){ if(x % i == 0) {ans.push_back(i); if(i*i!=x){ ans.push_back(x / i);}}}sort(all(ans)); return ans; } ll pop(ll x){return __builtin_popcountll(x);} ll poplong(ll x){ll y=-1;while(x){x/=2;y++;}return y;} P hyou(P a){ll x=gcd(abs(a.fi),abs(a.se));a.fi/=x;a.se/=x;if(a.se<0){a.fi*=-1;a.se*=-1;}return a;} P Pplus(P a,P b){ return hyou({a.fi*b.se+b.fi*a.se,a.se*b.se});} P Ptimes(P a,ll b){ return hyou({a.fi*b,a.se});} P Ptimes(P a,P b){ return hyou({a.fi*b.fi,a.se*b.se});} P Pminus(P a,P b){ return hyou({a.fi*b.se-b.fi*a.se,a.se*b.se});} P Pgyaku(P a){ return hyou({a.se,a.fi});} void cincout(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout<< fixed << setprecision(15); } struct Timer{//タイマーの本体 from https://atcoder.jp/contests/ahc073/submissions/80099112 chrono::steady_clock::time_point st=chrono::steady_clock::now(); double t(){ auto diff=chrono::steady_clock::now()-st; chrono::duration dbdiff=diff; return dbdiff.count(); } }; int main(){ cincout(); Timer timer; const double tl=1.9; ll n; cin>>n; auto a=mvec(0LL,4*n); rep(i,4*n){ cin>>a[i]; a[i]--; } auto sc=mvec(0LL,n,n,3); rep(i,n){ rep(j,n){ sc[i][j][0]=abs(3*n-i-1-a[i])+abs(4*n-j-1-a[n+j])+abs(i-a[3*n-i-1])+abs(n+j-a[4*n-j-1]); sc[i][j][1]=abs(4*n-j-1-a[i])+abs(3*n-i-1-a[n+j])+abs(i-a[4*n-j-1])+abs(n+j-a[3*n-i-1]); sc[i][j][2]=abs(n+j-a[i])+abs(4*n-j-1-a[3*n-i-1])+abs(i-a[n+j])+abs(3*n-i-1-a[4*n-j-1]); } } ll sco=0; rep(i,n) rep(j,n) sco+=(i==j?sc[i][j][2]:sc[i][j][0]); P de; de.fi=0; de.se=0; auto bor=mvec(de,n); rep(i,n){ bor[i].fi=i; if(sc[i][i][1]tl) break; } } rep(i,n){ rep(j,n){ cout<<(j==bor[i].fi?bor[i].se:0); } cout<<"\n"; } return 0; }