#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

struct vertex{
    ll parent;ll rank;ll comp;vl vec;
};
 
typedef struct vertex vertex;
 
vertex ver[2000005];
 
ll find(ll n){
    ll x= n;
    while(x != ver[x].parent){
        x = ver[x].parent;
    }
    ll y = n;
    ll z= ver[y].parent;
    while(y!=z){
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}
 
void makeset(ll n){
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n){
    rep(i, n)   makeset(i);
}
 
void join(vl& x, vl& y){
    x.insert(x.end(), y.begin(), y.end());
}
 
void uni(ll x,ll y){
    ll px = find(x);
    ll py = find(y);
    if(px == py )   return;
    else if(ver[px].rank > ver[py].rank){ver[py].parent = px; ver[px].comp += ver[py].comp;join(ver[px].vec, ver[py].vec);}
    else if(ver[py].rank > ver[px].rank){ver[px].parent = py; ver[py].comp += ver[px].comp;join(ver[py].vec, ver[px].vec);}
    else{
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}


int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n, m;
        cin>>n>>m;
        vvl vec(n);
        vl lang(m);
        rep(i, n){
            ll k;
            cin>>k;
            ll x;
            rep(j, k){
                cin>>x;
                --x;
                vec[i].pb(x);lang[x] = i;
            }
        }
        initiate(n);
        rep(i, n){
            for(ll u : vec[i]){
                uni(i, lang[u]);
            }
        }
        if(ver[find(0)].comp == n)    cout<<"YES";
        else cout<<"NO";
    }
}

Measured memory_bytes: 108984