#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int const N = 500, M = 10000000;
int p[M / 10], p2[10000], sz;
ll an[N][N];
bool pr[M];

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main(){
	for (int i = 2; i * i < M; ++i)if (!pr[i])for (int j = i * i; j < M; j += i)pr[j] = true;
	f(i, 2, M)if (!pr[i])p[sz++] = i;
	int kk = 0;
	for (int i = 1999; i > 0; i -= 3){
		p2[kk++] = p[i];
		p2[kk++] = p[i - 1];
		p2[kk++] = p[i - 2];
		p2[kk++] = p[(1999-i) / 3];
		if (kk == 2000)break;
	}
	int n;
	scanf("%d", &n);
	if (n == 2) { printf("4 7\n23 10\n"); return 0; }
	f(i, 0, n)f(j, 0, n)an[i][j] = 1;
	kk = 0;
	for (int i = 0; i < n; i += 2, ++kk)for (int j = 0, z = i; j < n && z < n; ++j, ++z)an[z][j] *= p[kk];
	for (int j = 2; j < n; j += 2, ++kk)for (int i = 0, z = j; i < n && z < n; ++i, ++z)an[i][z] *= p[kk];
	for (int i = 0; i < 2*n - 1; i += 2, ++kk)for (int j = i < n ? 0 : i - n + 1, z = i < n ? i : n - 1; j < n && z >= 0; ++j, --z)an[z][j] *= p[kk];
	f(i, 0, n)for (int j = i + 1 & 1; j < n; j += 2)an[i][j] = 1 + lcm(i ? an[i - 1][j] : 1, lcm(i + 1 < n ? an[i + 1][j] : 1, lcm(j ? an[i][j - 1] : 1, j + 1 < n ? an[i][j + 1] : 1)));
	f(i, 0, n){
		printf("%lld", an[i][0]);
		f(j, 1, n)printf(" %lld", an[i][j]);
		printf("\n");
	}
}