n = int(input()) A = [[0] * n for _ in range(n)] for i in range(n): for j in range(n): A[i][j] = (i + j) % n + 1 for row in A: print(*row)