N = int(input()) a = list(range(1, N+1)) for _ in range(N): print(*a) a = [a.pop()] + a