#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#include <set>
#include <random>
#include <sstream>
#include <stack>
#include <deque>

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

int N, M;
vi G[300000];
int used[300000];

void dfs(int n) {
  used[n] = 1;
  for (int v : G[n]) {
    if (used[v]) continue;
    dfs(v);
  }
}

int main() {
  cin >> N >> M;
  rep(i,N) {
    int K;
    cin >> K;
    rep(j,K) {
      int L;
      cin >> L;
      L--;
      G[i].push_back(N+L);
      G[N+L].push_back(i);
    }
  }
  dfs(0);
  int f = 1;
  rep(i,N) if (!used[i]) f = 0;
  if (f) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}
