main = getContents >>= print . solve . map (map (abs . read) . words) . lines solve :: [[Int]] -> Int solve [[x, y], [x2, y2]] | x > x2 && y > y2 && x == y && x2 == y2 = x + 1 | otherwise = max x y