import math import sys def S(): return sys.stdin.readline().rstrip() def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int, sys.stdin.readline().rstrip().split()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LS(): return list(sys.stdin.readline().rstrip().split()) n = I() dx = [1, 0, -1, 0] dy = [0, 1, 0, -1] s = [[0]*n for _ in range(n)] x, y = 0, 0 d = 0 for i in range(1, n*n+1): s[y][x] = i nx = x + dx[d] ny = y + dy[d] if 0 <= nx < n and 0 <= ny < n and s[ny][nx] == 0: x, y = nx, ny else: d = (d + 1) % 4 x += dx[d] y += dy[d] for row in s: print(" ".join(map(lambda x: '{0:03}'.format(x), row)))