main=interact f f(m:s)=unlines[[s!!(0^(mod(y-x)(2*n)*mod(y+x)(2*n)))|x<-[0..2*n^2+y]]|n+1<-[read[m]],y<-[0..n]]