f=sum.map read.words s#(x:t)|f s==f t=s++'|':t|z<-s++[x]=z#t m@main=getLine>>=putStrLn.(""#)>>m