def main(): N = int(input()) ans = [[0] * N for i in range(N)] for i in range(N): s = i for j in range(N): ans[i][(s+j)%N] = j+1 print(*ans[i]) if __name__ == '__main__': main()