#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
const int N=20005;
set<ll> st;
int n,i,j,k,p[N],l,w1[N],w2[N];
bool v[N];
ll a[505][505];
ll gcd(ll a,ll b)
{
	if(!b)
		return a;
	return gcd(b,a%b);
}
ll LCM(ll a,ll b,ll c,ll d)
{
	ll rtn=a/gcd(a,b)*b;
	rtn=rtn/gcd(rtn,c)*c;
	rtn=rtn/gcd(rtn,d)*d;
	return rtn;
}
int main()
{
	scanf("%d",&n);
	for(i=2;i<=20000;++i)
	{
		if(!v[i])
			p[++l]=i;
		for(j=1;j<=l&&p[j]*i<=20000;++j)
		{
			v[p[j]*i]=true;
			if(i%p[j]==0)
				break;
		}
	}
	for(i=1;i<=n;++i)
		w1[i]=p[i];
	for(i=1;i<=n;++i)
		w2[i]=p[n+i];
	random_shuffle(w1+1,w1+1+n);
	random_shuffle(w2+1,w2+1+n);
	for(i=1;i<=n;++i)
		for(j=1;j<=n;++j)
			if((i+j)%2==0)
				a[i][j]=w1[(i+j)/2]*w2[(i-j+n+1)/2];
	for(i=0;i<=n+1;++i)
		a[0][i]=a[n+1][i]=a[i][0]=a[i][n+1]=1;
	for(i=1;i<=n;++i)
		for(j=1;j<=n;++j)
			if((i+j)&1)
			{
				a[i][j]=LCM(a[i-1][j],a[i+1][j],a[i][j-1],a[i][j+1])+1;
				while(st.count(a[i][j]))
					a[i][j]+=LCM(a[i-1][j],a[i+1][j],a[i][j-1],a[i][j+1]);
				st.insert(a[i][j]);
			}
	for(i=1;i<=n;++i)
	{
		for(j=1;j<=n;++j)
			printf("%lld ",a[i][j]);
		puts("");
	}
	return 0;
}
