main=interact$(reverse!).read r!n=unlines[unwords[r$take 3$r$" "++show(n*mod(y-2*x)n+mod(y-x+div n 2)n+1)|x<-[1..n]]|y<-[1..n]]