import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Char
import Data.List

-- space delimited integers
getVals::IO [Int]
getVals = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
 

-- space delimited strings
getStrings::IO [String]
getStrings = (map BS.unpack . BS.words) <$> BS.getLine

main::IO()
main = do 
    n:_<-getVals
    dat <- forM [1..n] (\_ -> do
        x:y:_ <- getVals
        return (x,y)
        )
    putStrLn $ if solver dat then "Yes" else "No"


solver::[(Int,Int)]->Bool
solver ls = 3 <= (safeMax $ map length $ filter (\ (h:_) -> h) $ group $ map (\ (x,y) -> x == y) ls)

safeMax::[Int]->Int
safeMax [] = 0
safeMax ls = maximum ls