judge :: [String] -> String judge (sa : pa : sb : pb : _) | pa' > pb' = sa | pb' > pa' = sb | otherwise = "-1" where pa' = read pa :: Integer pb' = read pb :: Integer main :: IO () main = putStrLn . judge . concat . map (take 2) . map words . lines =<< getContents