#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define int long long
using namespace std;
int pt[123456], s;
set<int>st;
void f() {
	for (int i = 1; i <= s; i++)pt[i] = i;
	return;
}
int root(int i) {
	if (pt[i] == i)return i;
	else return pt[i] = root(pt[i]);
}
void unite(int a, int b) {
	pt[root(b)] = root(a);
	root(b);
	return;
}
signed main() {
	int n;
	cin >> n >> s;
	f();
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		int p, q; cin >> p;
		st.insert(p);
		for (int i = 1; i < k; i++) {
			cin >> q;
			if (pt[p] != q && pt[q] != p)unite(p, q);
			st.insert(q);
		}
	}
	for (int i = 1; i <= s; i++) root(i);
	int key = pt[*(st.begin())];
	for (auto i = st.begin(); i != st.end(); i++) {
		if (*i != key && pt[*i] != key) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n"; return 0;
}