import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.numeric;


void main() {
    int n, m;
    scan(n, m);

    auto adj = new int[][](n + m, 0);

    foreach (i ; 0 .. n) {
        auto line = readln.split.to!(int[]);

        foreach (lang ; line[1 .. $]) {
            lang += n - 1;
            adj[i] ~= lang;
            adj[lang] ~= i;
        }
    }

    auto visited = new bool[](n + m);

    void dfs(int u) {
        visited[u] = 1;

        foreach (v ; adj[u]) {
            if (!visited[v]) {
                dfs(v);
            }
        }
    }

    dfs(0);

    foreach (i ; 0 .. n) {
        if (!visited[i]) {
            writeln("NO");
            return;
        }
    }

    writeln("YES");
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}