n = int(input()) for i in range(n): ans = [] for j in range(n): ans.append((i + j) % n + 1) print(*ans)