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