main=do x<-readLn;interact$unwords.(x#).words i#((x:y):z)=case(i-1)#(y:z)of(y:z)->(x:y):z i#([]:z)|i<0=[[]]|0<1=case(i#z)of z->[]:z