#include <bits/stdc++.h>

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

class UnionFind {
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) std::swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
private:
	std::vector<int> data;
};

int n, m;
bool use[100005];
int langnum;
int main()
{
	std::cin >> n >> m;
	UnionFind uf(m);

	int lfirst;
	for (int i = 0; i < n; ++i) {
		int k;
		std::cin >> k;
		int first;
		for (int j = 0; j < k; ++j) {
			int l;
			std::cin >> l;
			--l;
			if (i == 0 && j == 0)
				lfirst = l;
			if (j == 0)
				first = l;
			else
				uf.unionSet(first, l);

			if (!use[l]) {
				use[l] = true;
				++langnum;
			}
		}
	}

	if (uf.size(lfirst) == langnum)
		std::cout << "YES" << std::endl;
	else
		std::cout << "NO" << std::endl;
	return 0;
}
