#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const int dx[] = {1, 0, -1, 0, 0};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, k, l;

vector<vector<int>> g;

bool vis[200010];

void dfs(int v) {
    vis[v] = true;
    for (auto &i : g[v]) {
        if (!vis[i]) dfs(i);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    g.resize(n + m);
    for (int i = 0; i < n; ++i) {
        cin >> k;
        for (int j = 0; j < k; ++j) {
            cin >> l;
            l = l - 1 + n;
            g[i].emplace_back(l);
            g[l].emplace_back(i);
        }
    }

    dfs(0);
    for (int i = 0; i < n; ++i) {
        if (!vis[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}