import Control.Monad import Control.Arrow data Ans = YES | NO deriving Show ans _ [] = YES ans lim@((a,b),(u,v)) ((x@(y,z)):xs) | y == a || y == u || z == b || z == v = ans lim xs | otherwise = NO sol::[(Int,Int)] -> Ans sol xs = ans ((u1,v1),(u2,v2)) xs where (us,vs) = unzip xs f = minimum &&& maximum (u1,u2) = f us (v1,v2) = f vs fun [a,b] = (a,b) work = readLn >>= flip replicateM (fmap (fun.map read.words) getLine) >>= print.sol main = readLn >>= flip replicateM_ work