#include <iostream>

using i64 = long long;

const int P = 9000, Q = P + 7, N = 2000 + 7;

int n, k;
int isp[Q], pri[Q];
int a[N], b[N];
i64 v[N][N];

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	for (int i = 2; i <= P; ++i) {
		if (!isp[i]) pri[++k] = i;
		for (int j = 1; j <= k & i * pri[j] <= P; ++j) {
			isp[i * pri[j]] = 1;
			if (i % pri[j] == 0) break;
		}
	}
	int l = 1, r = n * 2 + 10, z = 1;
	for (int i = -n; i <= n; ++i)
		if (i % 2 == 0) a[i + n] = z ? pri[l++] : pri[r--], z ^= 1;
	for (int i = 2; i <= n * 2; ++i)
		if (i % 2 == 0) b[i] = z ? pri[l++] : pri[r--], z ^= 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if ((i + j) % 2 == 0) v[i][j] = a[i - j + n] * b[i + j];
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if ((i + j) % 2 == 1)
				v[i][j] = 1ll * a[i - j - 1 + n] * a[i - j + 1 + n] * b[i + j - 1] * b[i + j + 1] + 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j)
			printf("%lld ", v[i][j]);
		printf("\n");
	}
	return 0;
}
