N = int(input()) L = list(range(1, N + 1)) for i in range(N): ans = L[i:] + L[:i] print(*ans)