main=interact$unwords.map(>>=show).f.read f n=g[0..n-1] g[]=[] g z=[[x,p]|x<-z]++[[p,y]|y<-q]++g q where(p:q)=reverse z