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