n=int(input()) a=[i+1for i in range(n)] for i in range(n):print(*(a[i:]+a[:i]))