N=int(input()) p=[n+1 for n in range(N)] for i in range(N): print(*p) p=p[-2:]+p[:-2]