#include #include #include #include using namespace std; using namespace atcoder; using namespace __gnu_pbds; using ll=long long; using ld=long double; using vll=vector; using vvll=vector; using pll=pair; // using mint=modint; // template // using ordered_map=tree,rb_tree_tag,tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll dx[4]={0,1,0,-1}; ll dy[4]={1,0,-1,0}; ll N,x=1,y=1,d=0; cin>>N; vvll A(N+1,vll(N+1,0)); for(ll v=1;v<=N*N;++v){ //(x,y) 現在地 A[x][y]=v; //d は今の方向です //(x+dx[d],y+dy[d]) に行くつもり ll nx=x+dx[d],ny=y+dy[d]; if(nx<=0||nx>N||ny<=0||ny>N||A[nx][ny]!=0){ //壁にぶつかったので右折します d=(d+1)%4; nx=x+dx[d],ny=y+dy[d]; } x=nx,y=ny; } for(int i=1;i<=N;++i){ for(int j=1;j<=N;++j){ if(j>1)cout<<' '; cout<