#include<iostream>
#include<vector>
using namespace std;

const int MAX_N = 1e5 + 1;
const int MAX_M = 1e5 + 1;

bool is_checked[MAX_N + MAX_M];
vector<int> graph[MAX_N + MAX_M];

void dfs(int node) {
    is_checked[node] = true;
    for (int i = 0; i < graph[node].size(); i++) {
        if (is_checked[graph[node][i]]) continue;
        dfs(graph[node][i]);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int K, L;
    for (int i = 0; i < N; i++) {
        cin >> K;
        for (int j = 0; j < K; j++) {
            cin >> L;
            L--;
            graph[i].push_back(N + L);
            graph[N + L].push_back(i);
        }
    }
    dfs(0);
    for (int i = 0; i < N; i++) {
        if (!is_checked[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}