N = int(input()) a = [[0] * (N + 1) for i in range(N + 1)] for i in range(1, N + 1): for j in range(1, N + 1): a[i][j] = N if (2 * i - j) % N == 0 else (2 * i - j) % N for i in range(1, N + 1): print(*a[i][1:])