/*
Stranger than the comet as it streaks across the sky
Stranger than the truth I know before my open eyes
I have dealt in mysteries and trickery, of light to entertain
Looked into the abyss, called it by its name

I have plundered time itself, put the world inside it
And the mysteries, day and night, divide it
A plague of wonders, on your knees beside me
Know the secrets, you shall not deride us

My dreams of empire for my frozen queen
Will come to pass
Know me, the Magus
I am Dr. Dee
And this is my house

I am the master of the tides
I shame the mirror in my sight
What random music of the spheres across the years

Know this I will return to this land
Rebuild where the ruins did stand
Chain of the demons set free
Strange alchemy

Gather round the aimless and the feckless and the lame
Hear the master summon up the spirits by their names
I curse you Edward Kelly your betrayal for eternity is damned
Know you speak with demons you cannot command

Even as I looked into the glass then I was blinded
Burning by the Mortlake shore my house my books inside it
You have taken up my wife and lain beside her
Now the black rain on my house, the timbers burning

My dreams of empire for my frozen queen
Will come to pass
Know me, the Magus
I am Dr. Dee
And this was my house

I was the keeper of the books
I had the knowledge of the scrolls
But now through ignorance and fear
I cast a shadow through the years

Know this I will return to this land
Rebuild where the ruins did stand
Chain of the demons set free
Strange alchemy

Know this
I will return to this land
Rebuild where the ruins did stand
Chain of the demons set free
Strange alchemy

Know this
I will return to this land
Rebuild where the ruins did stand
Restore the knowledge memory
Strange alchemy
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600000;

int n;
vector<pair<int,int> > order;
int pi,pj;
long long ans[1031][1031];

map<long long,int> used;

long long gcd(long long a,long long b){
	while (a&&b)a>b?a%=b:b%=a;
	return a+b;
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

vector<int> ordr;

int mx_prime(int x){
	int res=1;
	for (int i=2;i*i<=x;i++){
		if (x==1)
			break;
		while (x%i==0){
			x/=i;
			res=i;
		}
	}
	if (x>1)
		res=max(res,x);
	return res;
}

vector<int> primes;

void backtrack(long long prod,int ps){
	if (prod>1e6)
		return;
	if (prod>1)
		ordr.push_back(prod);
	for (int i=ps;i<primes.size();i++){
		backtrack(prod*primes[i],i);
	}
}

int pr[N];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	n=500;

	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if (i%2==j%2)
				order.push_back(make_pair(i,j));
		}
	}

	primes.clear();
	for (int i=2;i<=100000;i++){
		if (pr[i]==0){
			for (int j=i*2;j<=100000;j+=i)
			{
				pr[j]=1;
			}
		}
	}

	for (int i=3;;i++){
		if (pr[i]==0){
			primes.push_back(i);
			if (primes.size()==2000)
				break;
		}
	}

//	cout<<primes.back()<<endl;

	for (int i=0;i<order.size();i++){
		pi=order[i].first;
		pj=order[i].second;
		int si=pi+pj;
		si/=2;
		int sj=pi-pj+n;
		sj/=2;
		//cout<<pi<<" "<<pj<<" "<<si<<" "<<sj<<endl;
		//cout<<"@"<<i<<" "<<pi<<" "<<pj<<endl;
		long long here=primes[si-1]*primes[sj-1];
		if (si>sj)
			here*=2;
		ans[pi][pj]=here;
		used[here]=1;
	}

	/*for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}*/
	long long mx=0;

	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if (i%2!=j%2){
				long long L=1;
				for (int di=-1;di<=1;di++){
					for (int dj=-1;dj<=1;dj++){
						if (abs(di)+abs(dj)!=1)
							continue;
						if (i+di<1||i+di>n||j+dj<1||j+dj>n)
							continue;
						L=lcm(L,ans[i+di][j+dj]);
					}
				}
				long long Q=L;
				while (used[Q+1])
					Q+=L;
				ans[i][j]=Q+1;
				used[Q+1]=1;
				mx=max(mx,Q+1);
			}
		}
	}

	cin>>n;

	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if (j>1)
				cout<<" ";
			cout<<ans[i][j];//<<" ";
		}
		cout<<endl;
	}

	/*cout<<mx<<" "<<log10(mx)<<endl;

	vector<pair<long long,pair<int,int> > > A;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			A.push_back(make_pair(ans[i][j],make_pair(i,j)));
		}
	}
	sort(A.begin(),A.end());
	for (int i=1;i<A.size();i++){
		if (A[i].first==A[i-1].first){
			cout<<"SHIT!"<<" "<<A[i].second.first<<" "<<A[i].second.second<<" "<<A[i-1].second.first<<" "<<A[i-1].second.second<<endl;
		}
	}
	cout<<"OK"<<endl;
*/

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 26100