#include <bits/stdc++.h>
using namespace std;
#define VI vector<int>
#define Graph vector<VI>

int main() {
    int n, m; cin >> n >> m;
    
    Graph G(n + m);

    for(int i = 0; i < n; ++i) {
        int many; cin >> many;
        for(int j = 0; j < many; ++j) {
            int a; cin >> a;
            a--;
            G[i].push_back(a + n);
            G[a + n].push_back(i);
        }   
    }
    
    vector<int> seen(n + m, 0);
    queue<int> Q;
    Q.push(0);

    while(!Q.empty()) {
        int node = Q.front();
        Q.pop();
        seen[node] = 1;
        for(auto temp : G[node]) {
            if(seen[temp])
                continue;
            Q.push(temp);
        }
    }

    for(int i = 0; i < n; ++i)
        if(seen[i] == 0) {
            cout << "NO\n";
            return 0;
        } 

    cout << "YES\n";
}