#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



template<int um> class UF { // from kmjp
public:
	vector<int> par;
	UF() { par = vector<int>(um, 0); rep(i, 0, um) par[i] = i; }
	int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
	void operator()(int x, int y)
	{
		x = operator[](x); y = operator[](y);
		if (x != y) par[x] = y;
	}
};
//-----------------------------------------------------------------
int N, M;
UF<101010> uf;
int idx[101010];
//-----------------------------------------------------------------
int main() {
	cin >> N >> M;

	rep(i, 1, M + 1) idx[i] = -1;

	rep(i, 0, N) {
		int K; scanf("%d", &K);
		rep(j, 0, K) {
			int L; scanf("%d", &L);
			if (idx[L] < 0)
				idx[L] = i;
			else
				uf(i, idx[L]);
		}
	}

	bool ok = true;
	rep(i, 0, N) if (uf[0] != uf[i]) ok = false;

	if (ok)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}