#include <bits/stdc++.h>
using namespace std;

struct UnionFind{
    vector<int> par;
    int cnt;
    UnionFind(int n) : par(n, -1), cnt(n) {}
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x != y){
            if(par[y] < par[x]) swap(x, y);
            par[x] += par[y]; par[y] = x; cnt--;
        }
    }
    int find(int x){
        return par[x] < 0 ? x : par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        return -par[find(x)];
    }
    int size(){
        return cnt;
    }
};

int main(){
    int n, m, k;
    cin >> n >> m;
    vector<int> v[m];
    for(int i = 0; i < n; i++){
        cin >> k;
        while(k--){
            int l;
            cin >> l;
            l--;
            v[l].push_back(i);
        }
    }
    UnionFind uf(n);
    for(int i = 0; i < m; i++){
        for(int j = 1; j < v[i].size(); j++){
            uf.unite(v[i][j], v[i][j-1]);
        }
    }
    cout << (uf.size() == 1 ? "YES" : "NO") << endl;
    return 0;
}