c=n=int(input()) s=range(1,n*n+1) l=[i for i in s] d=[1,n,-1,-n]*99 p=1 m=q=n-1 while m: for i in [0]*m:q+=d[p];c+=1;l[q]=c p+=1 if p%2:m-=1 for i in s:print(("%03d"+["\n"," "][i%n!=0])%l[i-1],end="")