#include<stdio.h>
#include<string.h>
#define max 10
int a[max] [max];
int main()
{
int n;
int x = 0,y = 0;
int tot = 0;
memset(a,0,sizeof(a));
scanf("%d",&n);
if(n <= 0 || 10<n)
{
printf("Please input a num n:(n>0 && n<=10)");
scanf("%d",&n);
}
tot = a[x = 0] [y = n-1] = 1;
while(tot < n*n)
{
while( (x+1) < n && !a[x+1][y] )
a[++x][y] = ++tot;
while( (y-1) >= 0 && !a[x][y-1] )
a[x][--y] = ++tot;
while( (x-1) >= 0 && !a[x-1][y] )
a[--x][y] = ++tot;
while( (y+1) < n && !a[x][y+1] )
a[x][++y] = ++tot;
}
for(x = 0;x < n; x++)
{
for(y = 0;y < n; y++)
printf("%3d",a[x][y]);
printf("\n");
}
return 0;
}