#include using namespace std; int dw[] = {1, 0, -1, 0}; int dh[] = {0, 1, 0, -1}; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; scanf("%d", &n); vector< vector > ans(n, vector(n, 0)); int dir = 0; int w = 0, h = 0; for (int i = 1; i <= n * n; i++) { ans[h][w] = i; if (i == n * n) break; int tw = w + dw[dir], th = h + dh[dir]; if (tw >= 0 && tw < n && th >= 0 && th < n && ans[th][tw] == 0) { w = tw; h = th; continue; } dir = (dir + 1) % 4; w += dw[dir]; h += dh[dir]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { printf("%03d", ans[i][j]); printf(j == n - 1 ? "\n" : " "); } } return 0; }