N = int(input()) [print(*[(I + J) % N + 1 for I in range(N)]) for J in range(N)]