#include <bits/stdc++.h>

using namespace std;

const int N = 510;
int p[10010];
vector<int> primes;
int a[N * 2], b[N * 2];

void init() {
    for (int i = 2; i < 10000; i++) {
        if (!p[i]) {
            for (int j = i + i; j < 10000; j += i) {
                p[j] = 1;    
            }
            primes.push_back(i);
        }
    }
}

long long res[N][N];
set<long long> has;

long long lcm(long long a, long long b) {
    long long c = __gcd(a, b);
    return (a / c) * b;
}

int main() {
    init();    
    int n;
    scanf("%d", &n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        a[i] = primes[cnt++];
    }   
    for (int i = 0; i < n; i++) {
        b[i] = primes[cnt++];
    }
    memset(res, -1, sizeof res);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if ((i + j) % 2 == 0) {
                int aa = i + j >> 1;
                int bb = (i - j + n) >> 1;
                res[i][j] = 1ll * a[aa] * b[bb];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if ((i + j) % 2 == 0) {
                continue;
            }
            long long foo = 1ll;
            if (i > 0) {
                foo = lcm(foo, res[i - 1][j]);
            }
            if (i + 1 < n) {
                foo = lcm(foo, res[i + 1][j]);
            }
            if (j > 0) {
                foo = lcm(foo, res[i][j - 1]);
            }
            if (j + 1 < n) {
                foo = lcm(foo, res[i][j + 1]);
            }
            int it = 1;
            while (has.count(foo * it)) {
                it++;
            }
            has.insert(foo * it);
            res[i][j] = foo * it + 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            printf("%lld ", res[i][j]);
        }
        printf("\n");
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)
typedef long long ll;

const int MAXN=505,MAXD=7919;
const int movx[4]={-1,0,1,0},movy[4]={0,1,0,-1};

int n; ll a[MAXN][MAXN];
bool vis[MAXD]; ll prime[MAXN<<1];

inline ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}

inline ll lcm(ll a,ll b){
	if(!a||!b) return a|b;
	return a/gcd(a,b)*b;
}

inline void judge(){
	int x,a[505][505];
	scanf("%d",&x); lor(i,1,x) lor(j,1,x) scanf("%d",&a[i][j]);

}

int main(){
	scanf("%d",&n);

	if(n==2) return printf("4 7\n23 10\n"),0;

	lor(i,2,MAXD){
		if(!vis[i]) prime[++prime[0]]=i;
		for(register int j=1;j<=prime[0]&&i*prime[j]<=MAXD;++j) vis[i*prime[j]]=true;
	}

	lor(i,1,n) lor(j,1,n) if(!((i+j)&1)){
		a[i][j]=prime[(i+j)>>1]*prime[n+(n+1)/2+(i-j)/2];
	}
	lor(i,1,n) lor(j,1,n) if((i+j)&1){
		a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
	}
	lor(i,1,n){
		lor(j,1,n) printf("%lld ",a[i][j]); printf("\n");
	}

	return 0;
}