#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,a[1100][1100];
int tot,p[110000]; bool vis[110000];
void init(){
	vis[1]=true;
	for (int i=2;i<=10000;i++){
		if (!vis[i]) p[++tot]=i;
		if (tot==1000) break;
		for (int j=1;j<=tot&&(i*p[j]<=10000);j++){
			vis[i*p[j]]=true;
			if (i%p[j]==0) break;
		}
	}
}
inline int lcm(int x,int y){
	if (!x||!y) return x|y;
	return x/__gcd(x, y)*y;
}
signed main(){
	init();
	scanf("%lld",&n);
	if (n==2){
		puts("4 7\n23 10");
		return 0;
	}
	for (int i=1;i<=n;i++) 
		for (int j=1;j<=n;j++)
			if (((i+j)&1)==0)
				a[i][j]=p[(i+j)/2]*p[(i-j+n+1)/2+n];
	
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (!a[i][j]) 
				a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i][j+1],a[i+1][j]))+1;
	for (int i=1;i<=n;i++){
		for (int j=1;j<n;j++) printf("%lld ",a[i][j]);
		printf("%lld\n",a[i][n]);
	}
	return 0;	
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
int p[MAXN], pn;
bool np[MAXN];

inline void init(int n) {
	register int i, j;
	np[1] = 1; p[0] = p[n] = 1;
	for(i = 2; i <= n; ++i) {
		if(!np[i])
			p[++pn] = i;
		for(j = 1; j <= pn && i * p[j] <= n; ++j) {
			np[i * p[j]] = 1;
			if(i % p[j] == 0)
				break;
		}
	}
}

int main() {
	register int i, j; init(1e4);
	scanf("%d", &N);
	for(i = 0; i < N; ++i) {
		for(j = 0; j < N; ++j) {
			int s = (i + j) >> 1, d = (i - j) >> 1;
			if((i ^ j) & 1) printf("%lld ", 1ll * p[s + 1] * p[d + N + (N >> 1) + 1]);
			else printf("%lld ", 1ll * p[s + 1] * p[s] * p[d + N + (N >> 1) + 1] * p[d + N + (N >> 1)] + 1);
		}
		puts("");
	}
	return 0;
}