#include <stdio.h>
#include <string.h>

int i,n,j;
int a[11][11];
int v1[6][6],v2[6][6],v3[6][6],v4[6][6];

bool verif(int v[6][6]) {
	int i,j;
	bool ok;
	ok=true;
	for (i=1; i<=n; i++)
		for (j=1; j<=n; j++)
			if (v[i][j]==1)
				if (a[i][j]==-2) {
					ok=false;
					break;
				}
	if (ok) return true;
	else return false;
}

void afis(int v[6][6]) {
	int i,j,r;
	printf("1\n");
	for (i=1; i<=n; i++) {
		for (j=1; j<=n; j++) {
			if (v[i][j]==1) r=1;
			else 
				if (a[i][j]==-2) r=-2;
			else
				r=0;
		if (j<n) printf("%d ",r);
		else printf("%d\n",r);
		}
	}
}

void afis1(int v[6][6]) {
	int i,j,r;
	printf("1\n");
	for (i=1; i<=n; i++) {
		for (j=1; j<=n; j++) {
			if (v[i][j]==1) r=1;
			else 
				if (a[i][j]==-2) r=-2;
			else
				r=0;
		if (j<n) printf("%d ",r);
		else printf("%d\n",r);
		}
	}
}


int main () {
	freopen("avioane.in","r",stdin);
	freopen("avioane.out","w",stdout);
	scanf("%d",&n);
	for (i=1; i<=n; i++) 
		for (j=1; j<=n; j++) scanf("%d",&a[i][j]);
	
	memset(v1,0,sizeof(v1));
	memset(v2,0,sizeof(v2));
    memset(v3,0,sizeof(v3));
    memset(v4,0,sizeof(v4));	
	//matrice1:
	for (i=1; i<=5; i++)  {
		v1[i][3]=1;
		v1[2][i]=1;
	}
	for (i=2; i<=4; i++) v1[4][i]=1;
	
	//matrice2:
	for (i=1; i<=5; i++) {
		v2[i][2]=1;
		v2[3][i]=1;
	}
	for (i=2; i<=4; i++) v2[i][4]=1;
	
	//matrice3 & 4:
	for (i=1; i<=5; i++) 
		for (j=1; j<=5; j++) {
			v3[i][j]=v1[6-i][j];
			v4[i][j]=v2[i][6-j];
		}
	if (n==5) {
		if (verif(v1)) afis(v1);
		else
			if (verif(v2)) afis(v2);
		else 
			if (verif(v3)) afis(v3);
			else 
				if (verif(v4)) afis(v4);
			else printf("0\n");
	}
	else 
		if (n>=6) {
			if (verif(v1)) afis1(v1);
			else
		    if (verif(v2)) afis1(v2);
		    else 
			if (verif(v3)) afis1(v3);
			else 
				if (verif(v4)) afis1(v4);
			else printf("0\n");
		}
	return 0;
	}
	
	
	
		
	