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 i in range(N): print(*A[i])