#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
const int INF = numeric_limits<int>::max()/2;

struct UF {
	vector<int> data;
	UF(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool find(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)];
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m;cin>>n>>m;
    UF uf(n);
    vector<vector<int>> v(m);
    for(int i=0;i<n;i++){
        int k;cin>>k;
        for(int j=0;j<k;j++){
            int l;cin>>l;l--;
            v[l].push_back(i);
        }
    }
    for(int i=0;i<m;i++){
        if(v[i].size()<2) continue;
        for(int j=1;j<(int)v[i].size();j++){
            uf.unite(v[i][j],v[i][j-1]);
        }
    }
    if(uf.size(0)==n) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
