#include<bits/stdc++.h>
using namespace std;
#define llong long long
int n;
llong a[550][550];
llong pri[2020],tot;
bool isprime(int x)
{
    for(int i=1;i<=tot&&pri[i]*pri[i]<=x;++i)
        if(x%pri[i]==0)return 0;
    return 1;
}
llong calc(int x,int y){return pri[(x+y)/2]*pri[(x-y+n+1)/2+(n+n)/2];}
int main()
{
    scanf("%d",&n);
    for(int i=2;tot<=1200;++i)
        if(isprime(i))pri[++tot]=i;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
            if((i+j)&1)printf("%lld ",calc(i-1,j)*calc(i+1,j)+1);
            else printf("%lld ",calc(i,j));
        puts("");
    }
    return 0;
}
