#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 10;
ll a[N][N];
int di[4] = {-1, 1, 0, 0};
int dj[4] = {0, 0, 1, -1};
ll LCM(ll x, ll y){
    return x / __gcd(x, y) * y;
}
bool valid(int i, int j){
    return (i >= 0 && i < N && j >= 0 && j < N);
}
void gen(){
    set<int> used;
    ll cur = 2;
    for(int i = 0; i < N; i++){
        for(int j = i % 2; j < N; j += 2){
            a[i][j] = cur++;
            used.insert(a[i][j]);
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(a[i][j] != 0) continue;
            ll val = 1;
            for(int d = 0; d < 4; d++){
                int ni = i + di[d], nj = j + dj[d];
                if(valid(ni, nj)){
                    val = LCM(val, a[ni][nj]);
                }
            }
            a[i][j] = val + 1;
            while(used.count(a[i][j])) a[i][j] += val;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    gen();
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cout << a[i][j] << " ";
        }
        cout << '\n';
    }
}
