#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
LL a[500][500];
vector<int> v[500][500];
const unsigned long long MX = LL(19e18);

bool isPrime(int x) {
    for (int i = 2; i * i <= x; ++i) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

set<LL> se;

unsigned long long gcd(unsigned long long a, unsigned long long b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

LL lcm(unsigned long long a, unsigned long long b) {
    assert(MX / a > b);
    return a * b / gcd(a, b);
}

void ap(vector<int> &a, vector<int> &b) {
    for (int x : b) {
        a.pb(x);
    }
}

int main() {
    scanf("%d", &n);
    if (n == 2) {
        cout << "4 7" << endl;
        cout << "23 10" << endl;
        return 0;
    }
    forn(i, n) forn(j, n) {
        a[i][j] = 1;
    }
    int pr = 2;
    for (int st = 0; st < 2 * n + 5; st += 2) {
        bool firstTime = true;
        for (int i = 0; i < n; ++i) {
            int j = st - i;
            if (j >= 0 && j < n) {
                if (firstTime) {
                    firstTime = false;
                    while (!isPrime(pr)) {
                        ++pr;
                    }
                }
                a[i][j] *= pr;
                v[i][j].pb(pr);
            }
        }
        if (!firstTime) {
            ++pr;
        }
    }
    for (int st = 0; st < n; st += 2) {
        bool firstTime = true;
        for (int i = 0; i < n; ++i) {
            int j = i + st;
            if (j >= 0 && j < n) {
                if (firstTime) {
                    firstTime = false;
                    while (!isPrime(pr)) {
                        ++pr;
                    }
                }
                a[i][j] *= pr;
                v[i][j].pb(pr);
            }
        }
        if (!firstTime) {
            ++pr;
        }
    }
    for (int st = 2; st < n; st += 2) {
        bool firstTime = true;
        for (int j = 0; j < n; ++j) {
            int i = j + st;
            if (i >= 0 && i < n) {
                if (firstTime) {
                    firstTime = false;
                    while (!isPrime(pr)) {
                        ++pr;
                    }
                }
                a[i][j] *= pr;
                v[i][j].pb(pr);
            }
        }
        if (!firstTime) {
            ++pr;
        }
    }

//    forn(i, n) {
//        forn(j, n) printf("%7d", (int)a[i][j]);
//        puts("");
//    }

    LL mx = 0;
    forn(i, n) forn(j, n) {
        if ((i + j) % 2 == 1) {
            LL res = 1;
            vector<int> vv;
            if (i > 0) ap(vv, v[i - 1][j]);
            if (i < n - 1) ap(vv, v[i + 1][j]);
            if (j > 0) ap(vv, v[i][j - 1]);
            if (j < n - 1) ap(vv, v[i][j + 1]);
            sort(vv.begin(), vv.end());
            res = vv[0];
            for (int i = 1; i < (int)vv.size(); ++i) {
                if (vv[i] != vv[i - 1]) {
                    res *= vv[i];
                }
            }
            res += 1;
            a[i][j] = res;
        }
    }

    forn(i, n) forn(j, n) {
        mx = max(mx, a[i][j]);
        assert(!se.count(a[i][j]));
        se.insert(a[i][j]);
    }

    forn(i, n) {
        forn(j, n) printf("%lld ", a[i][j]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 26624