from collections import deque
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())

    a = deque(range(1, N + 1))
    for _ in [0] * N:
        print(*a)
        a.rotate()


if not __debug__:
    import sys

    f = open(sys.argv[1], "r")
    sys.stdin = f

main()