N = int(input()) X = [[0] * N for _ in range(N)] for i in range(N): for j in range(N): X[2 * (i - j) % N][2 * j % N] = i + 1 for i in range(N): print(*X[i])