#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if(y < x) x = y; } template static void amax(T &x, U y) { if(x < y) x = y; } int main() { int N; while(~scanf("%d", &N)) { vector A(N, vi(N)); static const int dy[4] = { 0, 1, 0, -1 }, dx[4] = { 1, 0, -1, 0 }; int d = 0, y = 0, x = 0; rep(k, N * N) { A[y][x] = k + 1; if(k= N || xx < 0 || xx >= N) && (A[yy][xx] == 0); if(ok) { y = yy, x = xx; break; } (++ d) %= 4; } } rep(i, N) { rep(j, N) { if(j != 0) putchar(' '); printf("%03d", A[i][j]); } puts(""); } } return 0; }