#include using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; using u128 = unsigned __int128; using i128 = __int128; constexpr int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; void solve() { int N; std::cin >> N; auto f = [&](int x) -> std::string { std::string s = std::to_string(x); while(s.size() < 3) s = "0" + s; return s; }; std::vector ans(N, std::vector (N, "")); auto ok = [&](int x, int y, int d) -> bool { int nx = x + dx[d], ny = y + dy[d]; if(nx < 0 || nx >= N || ny < 0 || ny >= N) return false; if(ans[nx][ny] != "") return false; return true; }; int x = 0, y = 0, d = 0; for(int i = 1; i <= N * N; i ++) { ans[x][y] = f(i); if(!ok(x, y, d)) d = (d + 1) % 4; x += dx[d]; y += dy[d]; } for(int i = 0; i < N; i ++) { for(int j = 0; j < N; j ++) std::cout << ans[i][j] << " "; std::cout << "\n"; } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int T = 1; //std::cin >> T; while (T--) { solve(); } return 0; }