#include using namespace std; #define rep(i, s, n) for (int i = (s); i < (int)(n); i++) #include using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; using ll = long long; using ull = unsigned long long; using ld = long double; ld pi=3.141592653589793; const int inf=2e9; const ll linf=2e18; const ld eps=1e-14; #define Yes cout << "Yes" << endl #define No cout << "No" << endl ll dx[4]={1,0,-1,0}; ll dy[4]={0,1,0,-1}; struct edge{ ll to; ll leng; }; int main() { ////////////////// ios::sync_with_stdio(false); cin.tie(nullptr); ////////////////// ll n; cin >> n; if(n==1) { cout << 1 << endl; return 0; }else if(n==2) { cout << "1 3" << endl; cout << "4 2" << endl; return 0; }else if(n==3) { cout << "1 4 8" << endl; cout << "6 2 3" << endl; cout << "7 5 9" << endl; return 0; } vector> a(n,vector(n)); a[0][0]=1,a[0][1]=4,a[0][2]=8; a[1][0]=6,a[1][1]=2,a[1][2]=3; a[2][0]=7,a[2][1]=5,a[2][2]=9; ll x=2,y=2; ll now=9; for(ll i=3; iy) { y++; now++; a[x][y]=now; }else { x++; now++; a[x][y]=now; } }else { swap(x,y); now++; a[x][y]=now; } }else { if(now==i*i+1) { x--; now++; a[x][y]=now; }else { if(now%2==0) { if(y