import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*

class UnionFind(val N: Int) {
    private val dt = IntArray(N+1){-1}
    fun root(key: Int): Int {
        return when {
            this.dt[key] < 0 -> {
                key
            }
            else -> {
                this.dt[key] = this.root(this.dt[key])
                this.dt[key]
            }
        }
    }
    fun unite(KX: Int, KY: Int): Boolean {
        val (rx, ry) = Pair(this.root(KX), this.root(KY))
        return when (rx) {
            ry -> {
                false
            }
            else -> {
                val (ky, kx) = if (this.size(ry) <= this.size(rx)) Pair(ry, rx)
                else Pair(rx, ry)
                this.dt[kx] += this.dt[ky]
                this.dt[ky] = kx
                true
            }
        }
    }
    fun size(key: Int): Int {
        val rk = this.root(key)
        return -this.dt[rk]
    }
    fun isConnect(kx: Int, ky: Int): Boolean {
        return this.root(kx) == this.root(ky)
    }
}


fun solve() {
    val (N, M) = rd.readListInt()
    val KL = rd.readListIntCols(N)

    val uf = UnionFind(N+M)

    for (i in 0 until N) {
        for (j in KL[i].drop(1).map{it-1}) {
            uf.unite(i, N+j)
        }
    }

    var ok = true
    for (i in 0 until N-1) {
        if (uf.isConnect(i,i+1)) continue
        else ok = false
    }

    val ans = if (ok) "YES" else "NO"
    println(ans)

    return
}


//val rd = debug.Reader("etc", "cf16-final", "c", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readDouble: () -> Double = { br.readLine().toDouble() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readIntArray: () -> IntArray = { readListInt().toIntArray() }
    val readLongArray: () -> LongArray = { readListLong().toLongArray() }
    val readListStringCol: (Int) -> List<String> = { N -> (0 until N).map { readString() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { readListInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { readListLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 70300