n = int(input()) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] x, y, d = 0, 0, 0 tbl = [[0] * n for _ in range(n)] for i in range(n * n): tbl[x][y] = str(i+1).zfill(3) r, c = x + dx[d], y + dy[d] if r < 0 or r >= n or c < 0 or c >= n or tbl[r][c] != 0: d = (d + 1) % 4 x, y = x + dx[d], y + dy[d] for i in tbl: print(*i)