import numpy as np N = int(input()) odd = np.zeros(N, dtype=int) odd[0] = 1 odd[-1] = N + 1 odd[1:N // 2] = np.arange(N + 3, 2 * N, 2) odd[N // 2:-1] = np.arange(N - 1, 2, -2) even = np.zeros(N, dtype=int) even[:N // 2] = np.arange(N, 1, -2) even[N // 2:] = np.arange(N + 2, 2 * N + 1, 2) A = np.tile(np.arange(0, N * N, 2 * N), (N, 2)).T A[:N//2] += odd A[N//2:] += even for a in A: print(*a)