#include<bits/stdc++.h>

using namespace std;

const int MAXN = 2e5 + 10;

int n, m;
vector<int>	adj[MAXN];
bool vis[MAXN];

void dfs(int v){
	if (vis[v])	return;
	vis[v] = 1;
	for (int u:adj[v])
		dfs(u);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		int sz;	cin >> sz;
		adj[i].resize(sz);
		for (int j = 0; j < sz; j++){
			cin >> adj[i][j], adj[i][j] += n-1;
			adj[adj[i][j]].push_back(i);
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; i++)
		if (!vis[i])
			dfs(i), cnt++;
	if (cnt == 1)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}
