import Data.Functor import Control.Monad toTuple :: [Int] -> (Int, Int) toTuple [x, y] = (x, y) readPoint :: IO (Int, Int) readPoint = toTuple . map read . words <$> getLine solveOne :: IO () solveOne = do n <- readLn :: IO Int points <- replicateM n readPoint let xs = map fst points ys = map snd points maxX = maximum xs minX = minimum xs maxY = maximum ys minY = minimum ys onEdge (x, y) | (x == maxX || x == minX) && y >= minY && y <= maxY = True | (y == maxY || y == minY) && x >= minX && x <= maxX = True | otherwise = False allOnEdge = all onEdge points putStrLn $ if allOnEdge then "YES" else "NO" main = do q <- readLn :: IO Int replicateM q solveOne