#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>
// #include "utiltime.hpp"

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(double x) { ll m = (ll)sqrt(x); return m + (m * m <= (ll)(x) ? 0 : -1); }
ll ceilsqrt(double x) { ll m = (ll)sqrt(x); return m + ((ll)x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }

/*******************************************************/

// n = 1.5e6 -> size = 114155, 800 ms
vll list_prime_until(int n) {
	if (n < 2) return{};
	vll ret;
	list<ll> lists(n - 1);
	int x = 2;
	Loopitr(itr, lists) {
		*itr = x++;
	}
	auto begin_itr = lists.begin();
	while (begin_itr != lists.end() && (*begin_itr) * (*begin_itr) < (ll)n) {
		auto itr = begin_itr;
		itr++;
		while (itr != lists.end()) {
			if (*itr % *begin_itr == 0) itr = lists.erase(itr);
			else itr++;
		}
		begin_itr++;
	}
	Loopitr(itr, lists) {
		ret.push_back(*itr);
	}
	return ret;
}

int main() {
	quickio();
	int n; cin >> n;
	vvll table1(n, vll(n, 0));
	vvll table2(n, vll(n, 0));
	vvll ans(n, vll(n, 1));
	if (n == 2) {
		ans = { {2,3}, {5,16} };
	}
	else {
		vll primes = list_prime_until(10000);
		int p = 0;
		for (int k = 0; k < n; k += 2) {
			int i, j;
			i = k;
			j = 0;
			while (i < n) {
				table1[i][j] = primes[p];
				ans[i][j] *= primes[p];
				++i; ++j;
			}
			++p;
			if (k == 0) continue;
			i = 0;
			j = k;
			while (j < n) {
				table1[i][j] = primes[p];
				ans[i][j] *= primes[p];
				++i; ++j;
			}
			++p;
		}
		p = 999;
		for (int k = 0; k < n; k += 2) {
			int i, j;
			i = 0;
			j = k;
			while (j >= 0) {
				table2[i][j] = primes[p];
				ans[i][j] *= primes[p];
				++i; --j;
			}
			--p;
			if (k == n - 1) continue;
			i = n - 1;
			j = n - 1 - k;
			while (j < n) {
				table2[i][j] = primes[p];
				ans[i][j] *= primes[p];
				--i; ++j;
			}
			--p;
		}
		Loop(i, n) {
			Loop(j, n) {
				if (ans[i][j] == 1) {
					vll vals(4, 1);
					if (i - 1 >= 0) vals[0] = table1[i - 1][j];
					if (j + 1 < n) vals[0] = table1[i][j + 1];
					if (j - 1 >= 0) vals[1] = table1[i][j - 1];
					if (i + 1 < n) vals[1] = table1[i + 1][j];
					if (i - 1 >= 0) vals[2] = table2[i - 1][j];
					if (j - 1 >= 0) vals[2] = table2[i][j - 1];
					if (i + 1 < n) vals[3] = table2[i + 1][j];
					if (j + 1 < n) vals[3] = table2[i][j + 1];
					ans[i][j] = vals[0] * vals[1] * vals[2] * vals[3] + 1;
				}
			}
		}
	}
	printmx(ans);
}

Measured memory_bytes: 9008