#include <cstdio>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int N, M;
std::vector<int> G[200001];
bool used[200001];

void dfs( int v )
{
  used[v] = true;

  rep( i, G[v].size() ) if( !used[G[v][i]] )
    dfs( G[v][i] );

  return;
}

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, N )
  {
    int K;
    scanf( "%d", &K );

    rep( j, K )
    {
      int L;
      scanf( "%d", &L );
      --L;
      G[i].push_back( L+N );
      G[L+N].push_back( i );
    }
  }

  dfs( 0 );

  bool fl = true;

  rep( i, N )
    fl &= used[i];

  puts( fl ? "YES" : "NO" );

  return 0;
}