import Data.List solve :: [[Int]] -> String solve ps = if lined then "YES" else "NO" where (firstPointX:firstPointY:[]) = head ps lined = all (==firstPointX) (map (!!0) ps) || all (==firstPointY) (map (!!1) ps) main = do t <- readLn :: IO Int c <- getContents let ps = map (\l-> map (read::String->Int) $ words l) $ take t $ lines c putStrLn $ solve ps