#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

ll gcd(ll x,ll y){return (y==0?x:gcd(y,x%y));}

ll a[510][510];
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

bitset<10101> isp; vector<int> ps;
void init(){
   rep(i,2,10000)isp[i]=1;
   rep(i,2,10000)if(isp[i]){
      ps.push_back(i);
      for(int j=i*i;j<10000;j+=i)isp[j]=0;
   }
}

int main(){
   int n; cin>>n;
   if(n==2){
      cout<<"4 7"<<endl;
      cout<<"23 10"<<endl;
      return 0;
   }
   int idx=0;
   rep(i,0,n)rep(j,0,n)a[i][j]=1;
   init();
   for(int d=-n+(n&1);d<n;d+=2){
      rep(x,0,n)if(x+d>=0 and x+d<n){
         a[x][x+d]*=ps[idx];
      } idx++;
   }
   for(int d=0;d<=n*2-2;d+=2){
      rep(x,0,n)if(d-x>=0 and d-x<n){
         a[x][d-x]*=ps[idx];
      } idx++;
   }
   rep(i,0,n)rep(j,0,n)if((i+j)&1){
      a[i][j]=1;
      rep(k,0,4){
         int tx=i+dx[k],ty=j+dy[k];
         if(tx<0 or tx>=n or ty<0 or ty>=n)continue;
         a[i][j]=a[i][j]/gcd(a[i][j],a[tx][ty])*a[tx][ty];
      } a[i][j]++;
   }
   rep(i,0,n){
      rep(j,0,n)cout<<a[i][j]<<(j==n-1?'\n':' ');
   }
   return 0;
}