N=int(input()) S=[str(i+1) for i in range(N)]*2 for i in range(N): print(" ".join(S[i:i+N]))