#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 100001;
ll par[N];
ll n,m,kotoba[N];

void init(ll n){
	FOR(i,1,n+1)par[i]=i;
}
ll root(ll x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}
void unite(ll x,ll y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}

int main(){
	cin>>n>>m;
	FOR(i,0,N)kotoba[i]=-1;
	init(n);
	FOR(i,1,n+1){
		ll k;
		cin>>k;
		FOR(j,1,k+1){
			ll l;
			cin>>l;
			if(kotoba[l]==-1)kotoba[l]=i;
			else {
				unite(kotoba[l],i);
			}
		}
	}

	FOR(i,2,n+1){
		if(root(1)!=root(i)){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}