# -*- coding: utf-8 -*- N = int(input()) chars = [] for i in range(N): temp = [''] * N chars.append(temp) direction = 0 row = col = 0 for i in range(1, pow(N,2)+1): chars[row][col] = i # 右向き if direction%4==0: if col == N-1 or chars[row][col+1] != '': direction += 1 row += 1 else: col += 1 # 下向き elif direction%4==1: if row == N-1 or chars[row+1][col] != '': direction += 1 col -= 1 else: row += 1 # 左向き elif direction%4==2: if col == 0 or chars[row][col-1] != '': direction += 1 row -= 1 else: col -= 1 # 上向き else: if row == 0 or chars[row-1][col] != '': direction += 1 col += 1 else: row -= 1 for i in range(N): for j in range(N): if j < N-1: print('{0:03d} '.format(chars[i][j]), end='') else: print('{0:03d}'.format(chars[i][j]))