import Data.Monoid main = getContents >>= putStrLn . solve . map (\x -> take (length x - 2) x) . lines solve :: [String] -> String solve [xs, ys] | cond == GT = sa | cond == LT = sb | otherwise = "-1" where cond = compare la lb `mappend` comp pa pb comp [] [] = mempty comp (a : as) (b : bs) = compare a b `mappend` comp as bs la = length pa lb = length pb f = takeWhile (/= ' ') g = dropWhile (/= ' ') sa = f xs sb = f ys pa = g xs pb = g ys