#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define ll long long
using namespace std;
typedef pair<char,int> pii;
set<ll>mapa;
const int maxv=2300000;
int n,pos[maxv+10],br;
ll primes[maxv],rows[1010],cols[1010],aa[519][510];
vector<ll>a[510][510];
void check(){

ll maxx=LONG_MIN;
ll minn=LONG_MAX;
set<ll>mapa2;
    for(int i=1;i<=n;i++){

        for(int j=1;j<=n;j++){

            if(i<n){
                mapa.insert(max(aa[i][j],aa[i+1][j])%min(aa[i][j],aa[i+1][j]));
            }
            if(j<n){
                mapa.insert(max(aa[i][j],aa[i][j+1])%min(aa[i][j],aa[i][j+1]));
            }

            maxx=max(maxx,aa[i][j]);
            minn=min(minn,aa[i][j]);
            mapa2.insert(aa[i][j]);
        }

    }
printf("%d %d %lld %lld\n",mapa.size(),mapa2.size(),maxx,minn);
}
void sito(){

    for(int i=2;i<=maxv;i++){
        if(pos[i])continue;
        primes[++br]=i;
        for(int j=i;j<=maxv;j+=i)pos[j]=1;
    }

}
ll lcm(ll a,ll b){
  return (a/__gcd(a,b))*b;
}
void fix(int x,int y){

    ll lc=1;

    if(aa[x+1][y]!=0){lc=lcm(lc,aa[x+1][y]);}
    if(aa[x-1][y]!=0){lc=lcm(lc,aa[x-1][y]);}
    if(aa[x][y+1]!=0){lc=lcm(lc,aa[x][y+1]);}
    if(aa[x][y-1]!=0){lc=lcm(lc,aa[x][y-1]);}

    aa[x][y]=lc+1;
}
int dist(int x,int y,int x1,int y1){
   return abs(x-x1)+abs(y-y1);
}
int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%d",&n);

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

    sito();

    int curr=0;
    for(int i=0;i<n;i++)
        rows[i*2]=primes[++curr];

    for(int i=0;i<n;i++)
        cols[i*2]=primes[++curr];

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){

            if(dist(1,1,i,j)%2==0){
                a[i][j].pb(rows[dist(1,1,i,j)]);
                aa[i][j]=rows[dist(1,1,i,j)];
            }

        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){

            if(n%2){
               if(dist(n,1,i,j)%2==0){
                a[i][j].pb(cols[dist(n,1,i,j)]);
                aa[i][j]*=cols[dist(n,1,i,j)];
               }
            }
            else{
                if(dist(n,1,i,j)%2==1){
                    a[i][j].pb(cols[dist(n,1,i,j)-1]);
                    aa[i][j]*=cols[dist(n,1,i,j)-1];
                }
            }

        }
    }


    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if((i+j)%2)fix(i,j);
            printf("%lld ",aa[i][j]);
        }
        printf("\n");
    }


    return 0;
}

#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 505
#define maxm 4010
#define inf 1000000007
#define mod 998244353
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int prime[100010],primesize;
bool notprime[100010];
void get_prime()
{
    for(int i=2;i<=100000;i++)
    {
        if(!notprime[i])   prime[++primesize]=i;
        for(int j=1;j<=primesize&&i*prime[j]<=100000;j++)
        {
            notprime[i*prime[j]]=true;
            if(i%prime[j]==0)  break;
        }
    }
}
ll ans[maxn][maxn];
int xx[4]={0,0,1,-1};
int yy[4]={1,-1,0,0};
bool check(int x,int y)
{
    return (x>=1&&x<=n&&y>=1&&y<=n);
}
ll gcd(ll x,ll y)
{
    if(!y)  return x;
    return gcd(y,x%y);
}
ll lcm(ll x,ll y)
{
    return x*(y/gcd(x,y));
}
int main()
{
    get_prime();
    n=read();
    int l=1,r=(n<<1)+(!(n&1));
    for(int i=2;i<=(n<<1);i+=2)
    {
        int val;
        if(i%4==0)  val=prime[l++];
        else        val=prime[r--];
        for(int x=1;x<=n;x++)
        {
            int y=(i-x);
            if(y<=0||y>n)  continue;
            ans[x][y]=val;
        }
    }
    for(int i=-(n-1)/2*2;i<=(n-1)/2*2;i+=2)
    {
        int val;
        if(i%4==0)  val=prime[l++];
        else        val=prime[r--];
        for(int x=1;x<=n;x++)
        {
            int y=(i+x);
            if(y<=0||y>n)  continue;
            ans[x][y]*=val;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if((i+j)&1)
            {
                for(int k=0;k<4;k++)
                {
                    int tx=i+xx[k],ty=j+yy[k];
                    if(check(tx,ty))
                    {
                        if(!ans[i][j])  ans[i][j]=ans[tx][ty];
                        else          ans[i][j]=lcm(ans[i][j],ans[tx][ty]);
                    }
                }
                ans[i][j]++;
            }
        }
    }
    if(n==2)  ans[1][2]=ans[1][2]*2-1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)  printf("%lld ",ans[i][j]);
        puts("");
    }
    return 0;
}