#include <fstream.h>

ifstream inpf ("input.txt");
ofstream outpf ("output.txt");

long int n;
long int *a[201];
long int *b[201];


int check(int i,int j)
{
if ((i<n)&&(i>=0)&&(j<n)&&(j>=0)) return 1;else return 0;
}

int checklevel(int i,int j,int l)
{
int mark=-1;

//long int ls;
for (int k=0;k<l;k++)
    {
    if (check(i+k,j-l+k))
	{
	if (a[i+k][j-l+k])
		{
		if (mark>=0)
			return 0;
		else
		mark=a[i+k][j-l+k];
		}
	}
    if (check(i+l-k,j+k))
	{
	if (a[i+l-k][j+k])
		{
		if (mark>=0)
			return 0;
		else
		mark=a[i+l-k][j+k];
		}
	}
    if (check(i-k,j+l-k))
	{
	if (a[i-k][j+l-k])
		{
		if (mark>=0)
			return 0;
		else
		mark=a[i-k][j+l-k];
		}
	}
    if (check(i-l+k,j-k))
	{
	if (a[i-l+k][j-k])
		{
		if (mark>=0)
			return 0;
		else
		mark=a[i-l+k][j-k];
		}
	}

    } //for
return mark;
}
void inpdata()
{
inpf >> n;

for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
	{
	inpf >> a[i][j];
	}

}

void outpdata()
{
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
	outpf <<  b[i][j]<<' ';
outpf<<endl;
}
}


void fm()
{
for (int i=0;i<201;i++)
	b[i]= new long int [201];
for (i=0;i<201;i++)
	a[i]= new long int [201];

}

void dm()
{
for (int i=0;i<201;i++)
       delete a[i];
for (i=0;i<201;i++)
       delete b[i];

}

int main()
{
fm();
inpdata();
outpf << n<<endl;
if (n==1){
		 b[0][0]=a[0][0];
		 cout << a[0][0]<<"  "<<n;
} else
{

for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
	{
	if (a[i][j]) b[i][j]=a[i][j];
	 else
		{
		int mark=-1;
		for (int k=1;(k<=2*n)&&(mark);k++)
			{
			 mark=checklevel(i,j,k);
			 if (mark>=0)
			  {b[i][j]=mark;mark=0;}

			}
		}
	}
}
outpdata();
dm();
return 0;
}

