/* イワナ */ #include #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() #define pb push_back #define fs first #define sc second #define show(x) cout << #x << " = " << x << endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) using namespace std; template ostream& operator<<(ostream& o,const pair &p){return o<<"("< ostream& operator<<(ostream& o,const vector &vc){o<<"sz = "<> a,vector> b){ int N = a.size(); int c = 0; vector aa; rep(i,N) rep(j,N) aa.pb(a[i][j]); rep(j,N*N) rep(i,j) if(aa[i]>aa[j]) c++; vector bb; rep(i,N) rep(j,N) bb.pb(b[i][j]); rep(j,N*N) rep(i,j) if(bb[i]>bb[j]) c++; rep(i,N) rep(j,N){ if(a[i][j] == N*N) c += i+j; if(b[i][j] == N*N) c += i+j; } return c%2==0; } int main(){ int N; cin>>N; vector> a(N,vector(N)); vector> b(N,vector(N)); rep(i,N) rep(j,N){ cin>>a[i][j]; if(a[i][j] == 0) a[i][j] = N*N; } if(N==1){ puts("possible"); puts("1"); return 0; } if(N==2){ puts("impossible"); return 0; } if(N%2==1){ int x = 0, y = N/2; rep(t,N*N){ b[x][y] = t+1; if(t%N != N-1){ x = (x+N-1)%N; y = (y+1)%N; }else{ x = (x+1)%N; } } if(!ok(a,b)){ swap(b[0],b[N-1]); } }else{ if(N%4==0){ rep(i,N) rep(j,N){ bool d = (i%4==j%4) || (i%4+j%4==3); if(d) b[i][j] = i*N+j+1; else b[i][j] = N*N+1 - (i*N+j+1); } }else{ int n = N/2; vector> c(n,vector(n)); int x = 0, y = n/2; rep(t,n*n){ c[x][y] = t*4; if(t%n != n-1){ x = (x+n-1)%n; y = (y+1)%n; }else{ x = (x+1)%n; } } rep(i,n) rep(j,n){ bool L = (i<=n/2); bool U = (i<=n/2+1) && !L; bool X = !L && !U; if((i==n/2 || i==n/2+1) && j == n/2) swap(L,U); if(L){ b[i*2][j*2] = c[i][j]+4; b[i*2][j*2+1] = c[i][j]+1; b[i*2+1][j*2] = c[i][j]+2; b[i*2+1][j*2+1] = c[i][j]+3; } if(U){ b[i*2][j*2] = c[i][j]+1; b[i*2][j*2+1] = c[i][j]+4; b[i*2+1][j*2] = c[i][j]+2; b[i*2+1][j*2+1] = c[i][j]+3; } if(X){ b[i*2][j*2] = c[i][j]+1; b[i*2][j*2+1] = c[i][j]+4; b[i*2+1][j*2] = c[i][j]+3; b[i*2+1][j*2+1] = c[i][j]+2; } } } if(!ok(a,b)){ rep(i,N/2) swap(b[i],b[N-1-i]); } } puts("possible"); rep(i,N){ rep(j,N) cout<