#include<cstdio>
int i,j,k,n,m,f[200001];
inline int g(int i)
{
	if(i==f[i])return i;
	return f[i]=g(f[i]);
}
int main()
{
	for(scanf("%d%d",&n,&m);++i<=n+m;f[i]=i);
	for(i=0;++i<=n;)for(scanf("%d",&k);k--;f[g(j+n)]=g(i))scanf("%d",&j);
	for(k=g(n),i=1;i<n;++i)if(g(i)!=k)break;
	if(i<n)puts("NO");else puts("YES");
}