N=int(input())
for i in range(N):
    print(*[(i+j)%N+1 for j in range(N)])