k=int c=n=k(input()) r=range l=[i for i in r(1,n*n+1)] d=[1,n,-1,-n]*1000 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,n*n+1):print(("%03d"+["\n"," "][i%n!=0])%l[i-1],end="")