#include using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int offset = (n/2 + 1)/2 - 1; int sh = n/2; vector> ans(n,vector(n)); rep(i,n*n/4){ int h = i%sh; int w = i/sh; ans[h][w] = 4*i + 1; ans[(h+offset)%sh][w+sh] = 4*i+2; ans[sh+h][w] = 4*i+3; ans[sh+(h+offset)%sh][sh+w] = 4*i+4; } rep(i,n){ rep(j,n){ cout << ans[i][j] << " \n"[j==n-1]; } } return 0; }