# coding: utf-8 INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def read(): N = II() return (N,) def solve(N): ans = [[None] * N for __ in range(N)] # [y][x] limit_right = N limit_left = -1 limit_top = 0 limit_bottom = N now_x = 0 now_y = 0 count = 1 state = 0 # 0 : right, 1: down, 2: left, 3: up while count != (N ** 2 + 1): if state == 0: if now_x + 1 == limit_right: limit_right = now_x state = (state + 1) % 4 else: ans[now_y][now_x] = count count += 1 now_x += 1 elif state == 1: if now_y + 1 == limit_bottom: limit_bottom = now_y state = (state + 1) % 4 else: ans[now_y][now_x] = count count += 1 now_y += 1 elif state == 2: if now_x - 1 == limit_left: limit_left = now_x state = (state + 1) % 4 else: ans[now_y][now_x] = count count += 1 now_x -= 1 elif state == 3: if now_y - 1 == limit_top: limit_top = now_y state = (state + 1) % 4 else: ans[now_y][now_x] = count count += 1 now_y -= 1 row_ans = [] for row in ans: for i in range(N): if len(str(row[i])) == 1: row[i] = "00{}".format(row[i]) if len(str(row[i])) == 2: row[i] = "0{}".format(row[i]) if len(str(row[i])) == 3: row[i] = "{}".format(row[i]) row_ans.append(" ".join(row)) ans = "\n".join(row_ans) return ans def main(): params = read() print(solve(*params)) if __name__ == "__main__": main()