N=int(input()) ANS=[[0]*N for i in range(N)] for i in range(N//2): for j in range(N//2): ANS[i][j]=i*N+(j*2+1) for i in range(N//2): for j in range(N//2): ANS[i][N-1-j]=i*N+(j*2+1)+N*N//2 for i in range(N//2): for j in range(N//2): ANS[i+N//2][N//2-1-j]=i*N+(j*2+1)+N*N//2+1 for i in range(N//2): for j in range(N//2): ANS[i+N//2][j+N//2]=i*N+(j*2+1)+1 for ans in ANS: print(*ans)