import Data.List import Control.Applicative import Control.Monad main = do n <- readLn c <- (map . map) (read :: String -> Int) . map words <$> replicateM n getLine let c' = map (\x -> x !! 1 - x !! 0) c print $ if and $ map (== (head c')) c' then if head c' <= 0 then -1 else head c' else -1