import List main@f=do s@(h:t)<-getLine;let m=sort[v++s|v<-tails t]in putStrLn$show(elemIndices s m!!0)++' ':map(!!length t)m;f