#include using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) #define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--) #define all(a) (a).begin(),(a).end() #define printV(v) for(auto&& x : v){cerr << x << " ";} cerr << endl #define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cerr << x << " ";}cerr << endl;} typedef long long ll; typedef pair Pii; typedef pair Pll; typedef tuple TUPLE; typedef vector V; typedef vector VV; typedef vector VVV; typedef vector> Graph; const int inf = 1e9; const int mod = 1e9 + 7; // N, E, S, W const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = { 0, 1, 0, -1}; int n; inline bool inside(int x, int y) { return 0 <= x && x < n && 0 <= y && y < n; } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); cin >> n; VV a(n, V(n)); int x = 0, y = 0; int d = 1; rep(i, n * n) { a[x][y] = i + 1; if (!inside(x + dx[d], y + dy[d]) || a[x + dx[d]][y + dy[d]] != 0) { d = (d + 1) % 4; } x += dx[d], y += dy[d]; } rep(i, n) { rep(j, n) { cout << (j != 0 ? " " : "") << setfill('0') << setw(3) << a[i][j]; } cout << endl; } }