#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int digit[50];
void solve(){
    int n;
    cin >> n;
    if(n==0){
        print(0);
        return;
    }
    bool plus=true;
    if(n<0) {
        plus=false;
        n=-n;
    }
    int ctr=0;
    while(n>0){
        if(n&1){
            digit[ctr]=1;
        }
        ctr++;
        n/=2;
    }
    if(plus){
        for(ll i=ctr-1; i>0; i--){
            if(i&1){
                if(digit[i]==1) digit[i+1]++;
            }
        }
        repi(i,1,45){
            while(digit[i]>1){
                digit[i+1]++;
                digit[i+2]++;
                digit[i]-=2;
            }
        }
    }
    else{
        for(ll i=ctr-1; i>=0; i--){
            if(i%2==0){
                if(digit[i]==1) digit[i+1]++;
            }
        }
        repi(i,1,45){
            while(digit[i]>1){
                digit[i+1]++;
                digit[i+2]++;
                digit[i]-=2;
            }
        }
    }
    bool start=false;
    for(ll i=38;i>=0;i--){
        if(!start&&digit[i]==0) continue;
        if(!start&&digit[i]==1){
            start=true;
            cout << digit[i];
            continue;
        }
        cout << digit[i];
    }
    cout << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[505][505];
bool chk[23333333];
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
int nxtPrime(int&x){
    auto chk=[&](int x){
        if(x<2)return false;
        for(int i=2;i*i<=x;i++)
            if(x%i==0)
                return false;
        return true;
    };
    do x++;while(!chk(x));
    ::chk[x]=true;
    return x;
}
void CCC(int n){
    map<int,pair<int,int>>s;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            if(s.count(a[i][j])){
                cout<<s[a[i][j]].first<<" "<<s[a[i][j]].second<<" "<<i<<" "<<j<<"\n";
                break;
            }
            s[a[i][j]]=make_pair(i,j);
        }
}
void solve(int n){
    int p=0;
    for(int i=1,j=n-(~n&1);i<=n;i++,j--)
        if(!a[i][j]&&1<=j&&j<=n)
            a[i][j]=nxtPrime(p);
    for(int i=n,j=n;i>=1;i--,j--)
        if(!a[i][j])
            a[i][j]=nxtPrime(p);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if((i+j)%2==0){
                if(a[i][j])continue;
                auto get=[&](int dx,int dy)->ll{
                    int x=i,y=j;
                    while(1<=x&&x<=n&&1<=y&&y<=n){
                        if(chk[a[x][y]])return a[x][y];
                        x+=dx,y+=dy;
                    }
                    return 1;
                };
                a[i][j]=get(+1,+1)*get(+1,-1)*get(-1,+1)*get(-1,-1);
            }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if((i+j)%2==1){
                auto upd=[&](int dx,int dy){
                    if(a[i+dx][j+dy])
                        a[i][j]=lcm(a[i][j],a[i+dx][j+dy]);
                };
                a[i][j]=1;
                upd(+1,0);
                upd(-1,0);
                upd(0,+1);
                upd(0,-1);
                a[i][j]++;
            }
}
int main(){
    solve(500);
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cout<<a[i][j]<<" \n"[j==n];
    return 0;
}