#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

const int N=100005;

int n,m,k,x,rt;
int f[N];
vector<int> lev[N];

int find(int k){
	if (f[k]!=k) f[k]=find(f[k]);
	return f[k];
}

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		scanf("%d",&k);
		for (j=1;j<=k;j++){
			scanf("%d",&x);
			lev[x].push_back(i);
		} 
	}
	for (i=1;i<=n;i++) f[i]=i;
	for (i=1;i<=m;i++){
		if (!lev[i].size()) continue;
		rt=find(lev[i][0]);
		for (j=1;j<lev[i].size();j++){
			x=find(lev[i][j]);
			f[x]=rt;
		}
	}
	for (i=2;i<=n;i++)
		if (find(i)!=find(i-1)){
			printf("NO\n");
			return 0;
		}
	printf("YES\n");
	return 0;
} 