#include <bits/stdc++.h>
using namespace std;
const int C=1;
map<long long,int> mp;
long long lcm(long long x,long long y){
	if (!(x&&y)) return x^y;
	return (__int128)x*y/__gcd(x,y);
}
const int N=600;
int z[N][N],n,a[N*N];
int main(){
	scanf("%d",&n);
	int tot=((n*n)+1)/2;
	for (int i=1; i<=tot; ++i) a[i]=i*2;
	random_shuffle(a+1,a+tot+1);
	int d=0;
	for (int i=1; i<=n; i++)
		for (int j=((i&1)?1:2); j<=n; j+=2)
			z[i][j]=a[++d];
	/*for (int i=1; i<=n; ++i,putchar('\n'))
		for (int j=1; j<=n; ++j) printf("%d ",z[i][j]);
		cerr<<"tot"<<tot<<endl;*/
	for (int i=1; i<=n; i++)
		for (int j=((i&1)?2:1); j<=n; j+=2){
			long long k=lcm(z[i-1][j],lcm(z[i][j-1],lcm(z[i+1][j],z[i][j+1])));
			long long zz=k;
			while (mp.find(zz+C)!=mp.end()) zz+=k;
			z[i][j]=zz+C;
			mp[zz+C]=1;
		}
	for (int i=1; i<=n; ++i,putchar('\n'))
		for (int j=1; j<=n; ++j) printf("%d ",z[i][j]);
}
