#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int N; bool isOK( int x, int y ) { return x >= 0 && y >= 0 && x < N && y < N; } int main() { cin >> N; vector< vector > V( N, vector( N, -1 ) ); int D[4][2] = { {1,0}, {0,1}, {-1,0}, {0,-1} }; int a = 1; int i = 0; int x = 0, y = 0; int c = 0; V[0][0] = a; while ( true ) { int nx = x + D[i%4][0]; int ny = y + D[i%4][1]; if ( isOK( nx, ny ) && V[nx][ny] == -1 ) { a++; V[nx][ny] = a; x = nx; y = ny; c = 0; } else { i++; c++; } if ( c == 4 ) { break; } } for ( int y = 0; y < N; y++ ) { for ( int x = 0; x < N; x++ ) { printf( "%03d", V[x][y] ); if ( x != N-1 ) { cout << " "; } } cout << endl; } return 0; }