#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

struct UnionFind{
    vector<int>p,r;
    UnionFind(int n){
        p.resize(n,-1);
        r.resize(n,1);
    }
    int find(int x){
        if(p[x]==-1)return x;
        else return p[x]=find(p[x]);
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(r[x]>r[y])swap(x,y);
        if(r[x]==r[y])r[y]++;
        p[x]=y;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n+m);
    rep(i,n){
        int k; cin>>k;
        rep(j,k){
            int l; cin>>l; l--;
            uf.unite(i,l+n);
        }
    }
    bool ok=true;
    rep(i,n-1){
        if(!uf.same(i,i+1))ok=false;
    }
    printf(ok?"YES\n":"NO\n");
}