#include using namespace std; //* #include using namespace atcoder; using mint = modint998244353; // using mint = modint1000000007; //*/ using ll = long long; using i128 = __int128_t; using pll = pair; using tlll = tuple; using ld = long double; const int INF = 1000100100; const ll INFF = 1000100100100100100LL; const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0}; #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(i, n) for (ll i = 0; i < ll(n); i++) #define rep2(i, l, r) for (ll i = ll(l); i < ll(r); i++) #define rep3(i, l, r, d) for (ll i = ll(l); (d) > 0 ? i < ll(r) : i > ll(r); i += d) #define rep(...) overload4(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) #define per(i, n) for (int i = (n) - 1; i >= 0; --i) #define yesno(f) cout << (f ? "Yes" : "No") << endl; #define YESNO(f) cout << (f ? "YES" : "NO") << endl; #define all(a) (a).begin(), (a).end() #define popc(x) __builtin_popcountll(ll(x)) template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second; } template void printvec(const vector &v) { int n = v.size(); rep(i, n) cout << v[i] << (i == n - 1 ? "" : " "); cout << '\n'; } template void printvect(const vector &v) { for (auto &vi : v) cout << vi << '\n'; } template void printvec2(const vector> &v) { for (auto &vi : v) printvec(vi); } template bool chmax(S &x, const T &y) { return (x < y) ? (x = y, true) : false; } template bool chmin(S &x, const T &y) { return (x > y) ? (x = y, true) : false; } #ifdef LOCAL // https://zenn.dev/sassan/articles/19db660e4da0a4 #include "cpp-dump-main/dump.hpp" #define dump(...) cpp_dump(__VA_ARGS__) CPP_DUMP_DEFINE_DANGEROUS_EXPORT_OBJECT(val()); #else #define dump(...) #endif struct io_setup { io_setup() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(15); } } io_setup; void solve() { int n; cin >> n; vector> ans(n, vector(n)); int id = 0; auto dfs = [&](auto dfs, int z) -> void { dump(z); if (z == 0) return; if (z == 1) { ans[n / 2][n / 2] = id + 1; return; } int res = (z - 1) * 4; vector num; for (int i = 1; i <= res; i += 4) { num.push_back(i); num.push_back(i + 1); } for (int i = 3; i <= res; i += 4) { num.push_back(i); num.push_back(i + 1); } int x = (n - z) / 2; dump(x); vector v; rep(i, z) { v.emplace_back(x, x + i); } rep(i, 1, z - 1) { v.emplace_back(x + i, x + z - 1); } rep(i, 1, z) { v.emplace_back(x + i, x); } rep(i, 1, z) { v.emplace_back(x + z - 1, x + i); } dump(v); rep(i, v.size()) { ans[v[i].first][v[i].second] = id + num[i]; } dump(v, num); id += res; dfs(dfs, z - 2); return; }; dfs(dfs, n); printvec2(ans); } int main() { int t; // cin >> t; t = 1; while (t--) { solve(); } }