import List main=interact$f.words f(_:x)=sort[(y>>x,y++" ")|y<-x]>>=snd