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