#include <bits/stdc++.h>

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 2010;

typedef __int128 LL;

int n;
LL A[N][N];

int vis[N * 20], prm[N];

void init(int m) {
	int c = 0;
	For(i, 2, m) if (!vis[i]) {
		if (i != 2) prm[++c] = i;
		for (int j = i * 2; j <= m; j += i) vis[j] = true;
	}
}

LL gcd(LL x, LL y) {
	return !y ? x : gcd(y, x % y);
}

LL lcm(LL x, LL y) {
	return x * y / gcd(x, y);
}

int main() {

	scanf("%d", &n);

	if (n == 2) {
		puts("4 7\n23 10");
		return 0;
	}

	init(n * 20);

	int l = 1, r = n;
	for (int s = 2; s <= n * 2; s += 2) {
		int cur = s % 4 == 0 ? prm[l++] : prm[r--];
		For(i, 1, n) if (s - i >= 1 && s - i <= n)
			A[i][s - i] = cur;
	}
	l = n + 1, r = 2 * n;
	for (int s = n % 2 ? 2 : 3; s <= n * 2; s += 2) {
		int cur = s % 4 < 2 ? prm[l++] : prm[r--];
		For(i, 1, n) {
			int j = n + 1 + i - s;
			if (j >= 1 && j <= n) A[i][j] *= cur;
		}
	}

	For(i, 1, n) For(j, 1, n) if ((i + j) % 2) {
		LL S = 1;
		if (i > 1) S = lcm(S, A[i - 1][j]);
		if (j > 1) S = lcm(S, A[i][j - 1]);
		if (i < n) S = lcm(S, A[i + 1][j]);
		if (j < n) S = lcm(S, A[i][j + 1]);
		++S;
		A[i][j] = S;
	}

	For(i, 1, n) For(j, 1, n) printf("%lld%c", (long long)A[i][j], j == n ? '\n' : ' ');

	return 0;
}