
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */
case class Person(id: Int, langs: Seq[Int])

object Main extends App {
  val params = readLine.split(" ").map(_.toInt)
  val N = params(0)
  val M = params(1)

  val langs: Array[mutable.MutableList[Person]] = Array.fill(M)(mutable.MutableList[Person]())
  val ps = 0.until(N).map(x => {
    val p = Person(x, readLine.split(" ").drop(1).map(_.toInt - 1))
    p.langs.foreach(l => langs(l).+=(p))
    p
  })
  val p0 = ps(0)

  val unvisitedPersons = Array.fill(N)(true)
  val unvisitedLangs = Array.fill(M)(true)

  val visitingPersons = mutable.Stack[Person]()
  val visitingLangs = mutable.Stack[Int]()

  visitingPersons.push(p0)

  while(visitingPersons.size > 0) {
    val p = visitingPersons.pop()
    p.langs.filter(l => unvisitedLangs(l)).foreach(l => {
      unvisitedLangs(l) = false
      val pps = langs(l)
      pps.filter(pp => unvisitedPersons(pp.id)).foreach(pp => {
        unvisitedPersons(pp.id) = false
        visitingPersons.push(pp)
      })
    })
  }
  if(unvisitedPersons.forall(_ == false)) {
    println("YES")
  } else {
    println("NO")
  }
}