#include<bits/stdc++.h>
#define int long long
#define maxn 100001
using namespace std;
int n, prime[maxn], d[maxn], a[maxn], f[1001][1001], ans, cnt;
int val1[maxn], val2[maxn];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	for(int i = 2; i <= 10000; i++){
		if(!d[i] && i != 2) prime[++cnt] = i;
		for(int j = i; j <= 10000; j += i) d[j] = 1;
	}
	cin >> n; cnt = 0;
	 for(int i = 1; i <= n ; i++)
    for(int j = 1; j <= n; j++)
      if (i + j & 1) {
      	if (!val1[i - j + n]) val1[i-j+n]=prime[++cnt];
      	f[i][j]=val1[i - j + n];
	  }
  for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n ; j++)
      if (i + j & 1) {
      	if (!val2[i + j]) val2[i + j]=prime[++cnt];
      	f[i][j]*=val2[i + j];
	  }
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
		{
			if(i + j & 1) continue; ans = 1;
			if(f[i - 1][j]) ans = ans / __gcd(f[i - 1][j], ans) * f[i - 1][j];
			if(f[i + 1][j]) ans = ans / __gcd(f[i + 1][j], ans) * f[i + 1][j];
			if(f[i][j + 1]) ans = ans / __gcd(f[i][j + 1], ans) * f[i][j + 1];
			if(f[i][j - 1]) ans = ans / __gcd(f[i][j - 1], ans) * f[i][j - 1];
			f[i][j] = ans + 1;
		}
	for(int i  = 1; i <= n; i++){
		for(int j = 1; j <= n; j++) printf("%lld ", f[i][j]);
		puts("");
	}
	return 0;
}
