n=int(input()) l=[[0 for i in range(n)] for j in range(n)] for d in range(n): k=(d*2)%n for r in range(n): l[d][r]=k+1 k=(k-1)%n for i in l: print(*i)