#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n, m, k, mem;
vector<int>p[100000];
vector<int>l[100000];
bool vtdp[100000], vtdl[100000];

int dfsl(int x);
int dfsp(int x);

int dfsp(int x) {
	lp(p[x].size()) {
		if (!vtdl[p[x][i]]) {
			vtdl[p[x][i]] = true;
			dfsl(p[x][i]);
		}
	}
	return 0;
}

int dfsl(int x) {
	lp(l[x].size()) {
		if (!vtdp[l[x][i]]) {
			vtdp[l[x][i]] = true;
			dfsp(l[x][i]);
		}
	}
	return 0;
}



int main() {
	cin >> n >> m;
	lp(n) {
		cin >> k;
		LP(k, j) {
			cin >> mem;
			p[i].push_back(mem - 1);
			l[mem - 1].push_back(i);
		}
	}
	lp(m)
		vtdl[i] = false;
	lp(n)
		vtdp[i] = false;
	vtdp[0] = true;
	dfsp(0);
	lp(n)
		if (!vtdp[i]) {
			cout << "NO" << endl;
			return 0;
		}
	cout << "YES" << endl;
	return 0;
}