import Data.List
main = do
    getLine
    l <- getIntLine <$> getContents
    putStrLn $ showans $ answer l
getInt :: String -> [Int]
getInt = tail . map read . words
getIntLine :: String -> [[Int]]
getIntLine = map getInt . lines

answer :: [[Int]] -> Bool
answer = (1 ==) . length . langgroup

showans :: Bool -> String
showans True = "YES"
showans False = "NO"

langgroup :: [[Int]] -> [[Int]]
langgroup (p:ps) = foldl langcon [p] ps

langcon :: [[Int]] -> [Int] -> [[Int]]
langcon langg newp = 
    let (a,b) = foldl foldfunc ([],newp) langg
        foldfunc (notint, int) x = 
            if x `intersect` newp /= [] 
            then (notint,int `union` x) 
            else (x:notint,int)
    in (b:a)
