#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

#define MAX_N 100005
#define int long long
vector<int> prime;
bool is_prime[MAX_N];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}
template<typename T>
T gcd(T a, T b)
{
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a,T b)
{
    return  a / gcd(a,b) * b;
}


signed main(){
    sieve(100000);
    map<int,int>p,q;
    int id = 0;
    for(int i=0;i<=600;i+=2){
        p[500-i] = prime[id];
        id++;
        q[i] = prime[id];
        id++;
        if(i!=0){
            p[500+i] = prime[id];
            id++;
            q[-i] = prime[id];
            id++;
        }
    }
    int n;
    cin >> n;
    set<ll>st;
    vector<vector<ll> > a(n,vector<ll>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if((i+j)%2==0){
                //cerr << p[i+j] << " " << q[i-j] << endl;
                a[i][j] = p[i+j]*q[i-j];
                if(st.count(a[i][j])){
                    assert(0);

                }
                st.insert(a[i][j]);
                
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if((i+j)%2==1){
                ll s = 1;
                if(i!=0){
                    s = lcm(s,a[i-1][j]);
                }
                if(i!=n-1){
                    s = lcm(s,a[i+1][j]);
                }
                if(j!=0){
                    s = lcm(s,a[i][j-1]);
                }
                if(j!=n-1){
                    s = lcm(s,a[i][j+1]);
                }
                s+=1;
                if(st.count(s)==1){
                    ll t = s-1;
                    while(1){
                        if(st.count(s)==0){
                            st.insert(s);
                            a[i][j] = s;
                            break;
                        }else{
                            s += t;
                        }
                    }
                }else{
                    a[i][j] = s;
                    st.insert(s);
                }
            }
        }
    }
    rep(i,n){
        rep(j,n){
            // if(a[i][j]>=1e15){
            //     cout << "ERROR " << a[i][j] << endl;
            //     return 0;
            // }
            cout << a[i][j];
            if(j!=n-1){
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 16896