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