import sys N=int(input()) d=[i+1 for i in range(N)]*2 m=0 for j in range(N): for k in range(N): sys.stdout.write(f"{d[k+m]}") if k==N-1: print() else: sys.stdout.write(" ") m+=1