#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;xN2/2+1) T[y][x]=2; } swap(T[N2/2][N2/2],T[N2/2+1][N2/2]); FOR(y,N2) FOR(x,N2) { if(T[y][x]==0) R[y*2][x*2]=RR[y][x]+4, R[y*2][x*2+1]=RR[y][x]+1; else R[y*2][x*2]=RR[y][x]+1, R[y*2][x*2+1]=RR[y][x]+4; if(T[y][x]!=2) R[y*2+1][x*2]=RR[y][x]+2, R[y*2+1][x*2+1]=RR[y][x]+3; else R[y*2+1][x*2]=RR[y][x]+3, R[y*2+1][x*2+1]=RR[y][x]+2; } } } void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(y,N) FOR(x,N) { cin>>A[y][x]; if(A[y][x]==0) A[y][x]=N*N; } if(N==2) return _P("impossible\n"); magic(N); _P("possible\n"); FOR(y,N*N) FOR(x,y) if(A[y/N][y%N]>A[x/N][x%N]) inv++; FOR(y,N*N) FOR(x,y) if(R[y/N][y%N]>R[x/N][x%N]) inv++; if(inv%2==0) return; FOR(y,N) FOR(x,N) _P("%d%c",R[y][x],(x==N-1)?'\n':' '); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }