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