N = int(input()) for i in range(N): for j in range(N): print((i + j) % N + 1,end = " ") print()