#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
	vector<int> data;
	UnionFind(int n) : data(n, -1) {}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool merge(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
};
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> L(M);
	for (int i = 0; i < N; ++ i) {
		int K;
		cin >> K;
		for (int j = 0; j < K; ++ j) {
			int x;
			cin >> x;
			L[x-1].push_back(i);
		}
	}
	UnionFind uf(N);
	for (auto& a : L) {
		for (int i = 1; i < a.size(); ++ i) {
			uf.merge(a[i-1], a[i]);
		}
	}
	if (N == -uf.data[uf.root(0)]) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}
