#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 a[510][510],primes[maxv],rows[510],cols[510];
void check(){

ll maxx=0;
    for(int i=1;i<=n;i++){

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

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

            maxx=max(maxx,a[i][j]);
        }

    }
printf("%d %lld\n",mapa.size(),maxx);
}
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*b)/__gcd(a,b);
}
void fix(int x,int y){

    ll lc=1;

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

    a[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);
    int sum=0;
    /// prvo blank
    if(n%2==0){
        sum+=(n/2)*(n/2);
        sum+=(n/2)*(n/2);
    }
    else{
        sum+=(n/2)*((n+1)/2);
        sum+=((n+1)/2)*(n/2);
    }

    sito();

    int curr=0;
    for(int i=1;i<=n;i++)rows[i*2]=primes[++curr];
    for(int i=1;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]=rows[i+j];

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

            if(dist(n,1,i,j)%2==0)a[i][j]*=cols[i+j];

        }
    }

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

        for(int j=2;j<=n;j+=2)a[i][j]=rows[i]*cols[j];
        for(int j=1;j<=n;j+=2)a[i+1][j]=rows[i+1]*cols[j];

    }

    ///printf("%d %lld %lld %lld SUM\n",sum,cols[100],rows[100],cols[100]*rows[100]);

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

            else printf("%lld ",a[i][j]);
        }
        printf("\n");
    }



    ///check();

    return 0;
}
