#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)



long long gcd(long long x, long long y){
    if(y==0)return x;
    return gcd(y,x%y);
}

int main(int argc, char const *argv[]) {
    int n;cin>>n;
    set<long long> used;
    long long M = 3;
    n+=2*M;
    vector<vector<long long>> res(n,vector<long long>(n,-1));
    long long s = 2;
    for(int i=1;i<n-1;++i){
        for(int k=1;k<n-1;++k){
            int tmpi = (i+k)%8,tmpk = (((i-k)%8)+8)%8;
            // if((tmpi==0&tmpk==0)||(tmpi==0&tmpk==4)||(tmpi==4&tmpk==2)||(tmpi==4&tmpk==6)){
            if((tmpi==0&tmpk==0)||(tmpi==4&tmpk==2)){
                long long ss = s;
                while(used.find(ss)!=used.end())ss*=2;
                res[i-1][k] = ss;
                used.insert(ss);
                while(used.find(ss)!=used.end())ss*=2;
                res[i+1][k] = ss;
                used.insert(ss);
                while(used.find(ss)!=used.end())ss*=2;
                res[i][k-1] = ss;
                used.insert(ss);
                while(used.find(ss)!=used.end())ss*=2;
                res[i][k+1] = ss;
                used.insert(ss);
                while(used.find(s)!=used.end())s+=1;
            }
        }
    }
    for(int i=n-2;i>0;--i){
        for(int k=1;k<n-1;++k){
            int tmpi = (i+k)%8,tmpk = (((i-k)%8)+8)%8;
            if((tmpi==0&tmpk==4)||(tmpi==4&tmpk==6)){
                long long ss = s;
                while(used.find(ss)!=used.end())ss*=2;
                res[i-1][k] = ss;
                used.insert(ss);
                while(used.find(ss)!=used.end())ss*=2;
                res[i+1][k] = ss;
                used.insert(ss);
                while(used.find(ss)!=used.end())ss*=2;
                res[i][k-1] = ss;
                used.insert(ss);
                while(used.find(ss)!=used.end())ss*=2;
                res[i][k+1] = ss;
                used.insert(ss);
                // while(used.find(ss)!=used.end())ss+=s;
                // res[i-1][k] = ss;
                // used.insert(ss);
                // while(used.find(ss)!=used.end())ss+=s;
                // res[i+1][k] = ss;
                // used.insert(ss);
                // while(used.find(ss)!=used.end())ss+=s;
                // res[i][k-1] = ss;
                // used.insert(ss);
                // while(used.find(ss)!=used.end())ss+=s;
                // res[i][k+1] = ss;
                // used.insert(ss);
                while(used.find(s)!=used.end())s+=1;
            }
        }
    }
    for(int i=M;i<n-M;++i){
        for(int k=M;k<n-M;++k){
            if((i+k)%2==0){
                long long tmp = 1,tt;
                tt = res[i+1][k];
                if(tt!=-1)tmp=(tmp/gcd(tmp,tt))*tt;
                tt = res[i-1][k];
                if(tt!=-1)tmp=(tmp/gcd(tmp,tt))*tt;
                tt = res[i][k+1];
                if(tt!=-1)tmp=(tmp/gcd(tmp,tt))*tt;
                tt = res[i][k-1];
                if(tt!=-1)tmp=(tmp/gcd(tmp,tt))*tt;
                tt = 1;
                while(used.find(tt*tmp+1)!=used.end())tt++;
                res[i][k] = tt*tmp+1;
                used.insert(tt*tmp+1);
            }
        }
    }
    for(int i=M;i<n-M;++i){
        for(int k=M;k<n-M;++k){
            cout<<res[i][k]<<" ";
        }
        cout<<endl;
    }
    // auto itr = used.end();
    // itr--;
    // cout<<*itr<<endl;
    // cout<<*used.begin()<<endl;
    return 0;
}

Measured memory_bytes: 16256