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