#include<bits/stdc++.h>
using namespace std;
int a,h,l,ans[1001][1001];
int asd(int n,int x,int y){
	if(x==1){
		return y;
	}
	if(y==n){
		return n+x-1;
	}
	if(x==n){
		return 3*n-1-y;
	}
	if(y==1){
		return 4*n-2-x;
	}
	return 4*(n-1)+asd(n-2,x-1,y-1);
}
int main(){
	scanf("%d",&a);
	
	for(int i=1;i<=a;i++){
		for(int j=1;j<=a;j++){
			cout<<setw(3)<<asd(a,i,j);
		}
		cout<<endl;
	}
	return 0;
}

/**************************************************************
	Problem: 1208
	User: zhengzihao
	Language: C
	Result: Compile Error
****************************************************************/