# Nは奇数、では偶数addで数字を動かしたらどうだろう # たとえばN=5なら、数字は1, 3, 5, 2, 4を基本ムーブとして組み合わせる N = int(input()) add = 2 basic = [0] for i in range(N-1): basic.append((basic[-1]+add)%N) basic = [a+1 for a in basic] A = [] for i in range(N): idx = basic.index(i+1) new = basic[idx-i:] + basic[:idx-i] A.append(new) for a in A: print(*a)