
import java.util.Scanner

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */

case class UnionFind(n: Int) {
  val sizes = Array.fill(n)(1)
  val par = 0.until(n).toArray
  var size = n

  def find(x: Int): Int = {
    if(par(x) == x) return x
    par(x) = find(par(x))
    par(x)
  }

  def unite(x: Int, y: Int): Boolean = {
    val parentX = find(x)
    val parentY = find(y)

    if(parentX == parentY) {
      return false
    }

    val (sId, lId) = if(sizes(parentX) < sizes(parentY)) {
      (parentX, parentY)
    } else {
      (parentY, parentX)
    }

    par(sId) = lId
    sizes(lId) += sizes(sId)
    sizes(sId) = 0

    size -= 1
    true
  }

  def isSame(x: Int, y: Int): Boolean = {
    return find(x) == find(y)
  }
}

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val M = sc.nextInt

  val uf = UnionFind(N + M)

  for(i <- 0 until N) {
    val K = sc.nextInt
    for(j <- 0 until K) {
      val l = sc.nextInt - 1
      uf.unite(i, l + N)
    }
  }

  if(1.until(N).forall(id => uf.isSame(0, id))) {
    println("YES")
  } else {
    println("NO")
  }
}