{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE LambdaCase, DeriveFunctor #-}

import           Control.Applicative
import           Control.Arrow
import           Control.Monad
import           Data.Bits
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import           Control.Monad.Fix
import qualified Data.Set                      as S



twice f x = f x x

both :: Arrow a => a b c -> a (b, b) (c, c)
both = twice (***)

readsLn :: Read a => IO [a]
readsLn = mapM readIO . words =<< getLine


main = do
  n <- readLn @Int
  a <- map (\[a, b] -> a == b) <$> replicateM n (readsLn @Int)
  putStrLn $ if f a then "Yes" else "No"
 where
  f [_, _] = False
  f (a : b : c : xs) | a && b && c = True
                     | otherwise   = f (b : c : xs)
