#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




ll n, m;
vector<vector<ll>> g;
bool used[200005];

void dfs(ll p){
    for(auto x : g[p]){
        if(!used[x]){
            used[x] = true;
            dfs(x);
        }
    }
}

int main() {
    cin >> n >> m;
    g.resize(n + m);
    REP(i, n){
        ll k;
        cin >> k;
        REP(j, k){
            ll l;
            cin >> l;
            l--;
            g[i].push_back(n + l);
            g[n + l].push_back(i);
        }
    }
    
    dfs(0);
    
    REP(i, n){
        if(!used[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}