#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define forg(i,gu) for (int i=gu;~i;i=e[i].next)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld "%I64d"
#else
#define lld "%lld"
#endif
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');
	c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
//const ll inf=0x3f3f3f3f3f3f3f3fll;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
//const int mo=0;
//int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}


ll a[555][555];

// tot = sieve(n)
// prime[1..tot] = {1<= prime <=n}
// bo[i]==1, i is composite ; bo[i]==0, i==1 or prime

//basic

const int SIEVE_MAXN=100000+5;
int prime[SIEVE_MAXN>100000?SIEVE_MAXN/10:10000];bool bo[SIEVE_MAXN];
int sieve(int n){
	int tot=0;
	for (int i=2;i<=n;i++){
		if (!bo[i])prime[++tot]=i;
		for (int j=1;j<=tot && prime[j]*i<=n;j++){
			bo[i*prime[j]]=1;
			if(i%prime[j]==0)break;
		}
	}
	return tot;
}

/////

map<int,int> ma,mb;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void gao(int n) {
	/*rep(i,1,3001) {
		prime[i]=3001+i;
	}*/
	int to=1;
	for (int i=-498;i<=1000;i+=2) {
		ma[i]=mb[i]=prime[++to];
		//mb[i]=prime[++to];
	}
	set<ll>se;
	rep(i,1,n+1)
		rep(j,1,n+1) {
			if((i+j)%2==0) {
				a[i][j] = 1ll*ma[i-j] *mb[i+j];
				if(se.count(a[i][j])>0) {
					a[i][j]*=2;
				}
				assert(se.count(a[i][j])==0);
				se.insert(a[i][j]);
			}
		}
	rep(i,1,n+1)
		rep(j,1,n+1) {
			if((i+j)%2!=0) {
				ll lm = 1;
				rep(k,0,4){
					int ii=i+dx[k],jj=j+dy[k];
					if(ii<1 || jj<1 || ii>n || jj>n)continue;
					ll b = a[ii][jj];
					lm = lm/gcd(lm,b)*b;
				}
				ll fa=lm+1;
				while(se.count(fa)>0)fa+=lm;
				a[i][j]=fa;
				se.insert(a[i][j]);
			}
		}

	ll ma = 0;
	rep(i,1,n+1)rep(j,1,n+1)upmax(ma,a[i][j]);
	//assert(ma<1e15);
	//cout<<double(ma)<<endl;

	//rep(i,1,n+1)rep(j,1,n+1)se.insert(a[i][j]);
	//cout<<se.size()<<endl;



}
int main()
{
	sieve(100000);
	gao(500);
	int n;
	gn(n);
	rep(i,1,n+1) {

		rep(j,1,n+1) {
			printf(lld,a[i][j]);
			if(j==n)printf("\n");
			else printf(" ");
		}

	}
	return 0;

}



Measured memory_bytes: 17152