import numpy as np def make_arr(N): arr = np.array([[1 for i in range(N)] for j in range(N)]) return arr def next_pos(start, dist, arr, N): # dist = 1(right), -1(left) k = start[0] l = start[1] pos = k,l while arr[k,l+dist] == 1: if (k,l+dist) == (0,0): break num = arr[k,l] l += dist arr[k,l] = num + 1 if l == N-1 or l == 0: break pos = l,k return pos def splitter(col): l = len(col) s = '' for i in range(l): s += '{0:0>3} '.format(col[i]) return s def main(): N = int(input()) if N == 1: print('001') else: arr = make_arr(N) i = 0 pos = 0,0 while i >= 0: phase = i % 4 pre_pos = pos if phase < 2: pos = next_pos(pre_pos, 1, arr, N) else: pos = next_pos(pre_pos, -1, arr, N) arr = arr.T if (pos[1], pos[0]) == pre_pos: col = arr.shape[0] for i in range(col): print( splitter(arr[i]) ) break else: i += 1 return 0 if __name__ == '__main__': main()