import Control.Applicative import Control.Monad import System.IO data Point = Point { getX :: Int, getY :: Int } deriving (Eq, Show) main :: IO () main = do n_temp <- getLine let n = read n_temp :: Int arr_temp <- getMultipleLines n let listOfPoints = map strToPoint arr_temp xCoordinates = map (getX) listOfPoints yCoordinates = map (getY) listOfPoints answer = if allEquals xCoordinates || allEquals yCoordinates then "YES" else "NO" putStrLn answer strToPoint :: String -> Point strToPoint str = let (x:y:[]) = words str in Point (read x) (read y) allEquals [] = True allEquals [_] = True allEquals (x:y:ys) = if x == y then allEquals (y:ys) else False getMultipleLines :: Int -> IO [String] getMultipleLines n | n <= 0 = return [] | otherwise = do x <- getLine xs <- getMultipleLines (n-1) let ret = (x:xs) return ret