main=interact$foldr(#)"" c#(d:r)|elem(c,d)$zip"><+-""<>-+"=r c#r=c:r