#include <bits/stdc++.h>

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 507;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n;
LL tab[N][N];
vector <int> primes;

LL nwd(LL a, LL b){
	if(b == 0)
		return a;
	return nwd(b, a%b);
}

LL get(LL a, LL b, LL c, LL d){
	LL ret = a / nwd(a, b) * b;
	ret = ret / nwd(ret, c) * c;
	ret = ret / nwd(ret, d) * d;
	return ret;
}

bool ok(int a){
	for(int i = 2; i * i <= a; ++i)
		if(a%i == 0)
			return false;
	return true;
}

int main(){
	scanf("%d", &n);
	if(n == 2){
		puts("2 3\n5 4");
		return 0;
	}

	for(int i = 2; primes.size() < n + n; ++i)
		if(ok(i))
			primes.push_back(i);
	
	for(int i = 0; i <= n + 1; ++i)
		for(int j = 0; j <= n + 1; ++j)
			tab[i][j] = 1;
	
	int sx = n - 1 + (n & 1), sy = 1;
	for(int i = 1; i <= n - 1 + (n & 1); ++i){
		int cx = sx, cy = sy;
		while(cx <= n && cy <= n){
			tab[cx][cy] *= primes.back();
			++cx, ++cy;
		}
		
		if(sx > 2)
			sx -= 2;
		else{
			if(sy == 1 && sx == 2)
				sx = 1, sy++;
			else
				sy += 2;
		}
		
		primes.pop_back();
	}
	
	sx = 1, sy = 1;
	for(int i = 1; i <= n; ++i){
		int cx = sx, cy = sy;
		while(cx <= n && cy >= 1){
			tab[cx][cy] *= primes.back();
			++cx, --cy;
		}
		
		if(sy + 1 < n)
			sy += 2;
		else{
			if(sx == 1 && sy + 1 == n)
				sy = n, ++sx;
			else
				sx += 2;
		}
		
		primes.pop_back();
	}
	
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			if((i + j) & 1)
				tab[i][j] = get(tab[i - 1][j], tab[i][j - 1], tab[i + 1][j], tab[i][j + 1]) + 1;
			printf("%lld ", tab[i][j]);
		}

		puts("");
	}
	
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)
typedef long long ll;

const int MAXN=505,MAXD=7919;
const int movx[4]={-1,0,1,0},movy[4]={0,1,0,-1};

int n; ll a[MAXN][MAXN];
bool vis[MAXD]; ll prime[MAXN<<1];

inline ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}

inline ll lcm(ll a,ll b){
	if(!a||!b) return a|b;
	return a/gcd(a,b)*b;
}

inline void judge(){
	int x,a[505][505];
	scanf("%d",&x); lor(i,1,x) lor(j,1,x) scanf("%d",&a[i][j]);

}

int main(){
	scanf("%d",&n);

	if(n==2) return printf("4 7\n23 10\n"),0;

	lor(i,2,MAXD){
		if(!vis[i]) prime[++prime[0]]=i;
		for(register int j=1;j<=prime[0]&&i*prime[j]<=MAXD;++j) vis[i*prime[j]]=true;
	}

	lor(i,1,n) lor(j,1,n) if(!((i+j)&1)){
		a[i][j]=prime[(i+j)>>1]*prime[n+(n+1)/2+(i-j)/2];
	}
	lor(i,1,n) lor(j,1,n) if((i+j)&1){
		a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
	}
	lor(i,1,n){
		lor(j,1,n) printf("%lld ",a[i][j]); printf("\n");
	}

	return 0;
}