(&)=zip [s,t]=" -" x%c=(c:x)&(x++[c]) (a:x)#y=a:y#x;x#_=x x?c=[last$s:[max a b|cs,b>s]|(a,b)<-x] v y=y%t?'|' f x=[v u&v d?s&(h%s?s)?'+'#h|(u,d)<-x%[t,t..],h<-[u&d?t]]#[v y#y|y<-x] main=interact$unlines.f.lines