#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll MAX = 10000000;
const int MAXN = 100010;

vector<int> g[MAXN * 2];

bool visited[MAXN * 2];

void bfs(int s){
    queue<int> Q;
    visited[s] = true;
    Q.push(s);
    while(!Q.empty()){
        int v = Q.front();
        // cout << v << endl;
        Q.pop();
        for(int r: g[v]){
            if(!visited[r]){
                visited[r] = true;
                Q.push(r);
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    for(int i=1;i<=N;i++){
        int k; cin >> k;
        for(int j=0;j<k;j++){
            int l; cin >> l;
            g[i].push_back(N+l);
            g[N+l].push_back(i);
        }
    }
    bfs(1);
    bool flag = true;
    for(int i=1;i<=N;i++){
        if(!visited[i]){
            flag = false;
            break;
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}