#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

vector<int> v[100001];
struct UnionFind{
    int data[100001]; 
    void init(int n){memset(data,-1,sizeof(data));}
    int find(int x){return data[x]<0?x:data[x]=find(data[x]);}
    void unite(int x, int y){
        x=find(x);y=find(y);       
        if(x!=y){
            if(data[y]<data[x]) swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return;
    } 
    bool same(int x, int y){return (find(x) == find(y));}
    int size(int x){return -data[x];}
};
int main(){
    int n,m,k,li;
    cin>>n>>m;
    rep(i,n){
        cin>>k;
        rep(j,k){
            cin>>li;
            v[li-1].pb(i);
        }
    }
    UnionFind uf;
    uf.init(n+1);
    rep(i,m){
        rep(j,(int)v[i].size()-1){
            uf.unite(v[i][j],v[i][j+1]);
        }
    }
    FOR(i,1,n){
        if(!uf.same(0,i)){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}