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