#include <stdio.h>

int N,M,par[200500];

int find(int x)
{
	if (x != par[x]) par[x] = find(par[x]);
	return par[x];
}

int main()
{
	scanf ("%d %d",&N,&M);
	for (int i=0;i<N+M;i++) par[i] = i;
	for (int i=0;i<N;i++){
		int x;scanf ("%d",&x);
		while (x--){
			int y; scanf ("%d",&y);
			y = y - 1 + N;
			par[find(i)] = find(y);
		}
	}

	for (int i=0;i<N;i++) if (find(i) != find(0)){
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}