#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0; i=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector VI; typedef vector VL; typedef vector VVI; typedef vector VVL; typedef pair P; typedef pair PL; typedef vector VD; typedef vector VVD; template void chmin(T &a, T b) { if (a > b) a = b; } template void chmax(T &a, T b) { if (a < b) a = b; } int in() { int x; scanf("%d", &x); return x; } ll lin() { ll x; scanf("%lld", &x); return x; } int main() { int n; cin >> n; VVI a(n, VI(n)); int c = 1, m = (n + 1) / 2; if (n % 2){ REP(i,m){ REP(j,i+1){ a[m - 1 + j][m - 1 + i - j] = c++; a[j][i - j] = c++; } } REP(i,m-1){ REP(j,m-1-i){ a[m + i + j][n - 1 - j] = c++; if (c < 2 * m * m) a[i + j + 1][m - 1 - j] = c++; } } REP(i,m-1){ REP(j,m-1){ a[i][m+j] = c++; a[m+i][j] = c++; } } }else{ REP(i,m){ REP(j,m){ a[i][j] = c++; a[m+i][m+j] = c++; } } REP(i,m){ REP(j,m){ a[i][m+j] = c++; a[m+i][j] = c++; } } } REP(i,n){ REP(j,n) cout << a[i][j] << " "; // REP(j,n) printf("%03d ", a[i][j]); cout << endl; } return 0; }