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