#include <bits/stdc++.h>
const double EPS = (1e-10);
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
Int mod_pow(Int x, Int n) {
  Int res = 1;
  for (int i = 0; i < 60; i++) {
    if (n >> i & 1) res = res * x % MOD;
    x = x * x % MOD;
  }
  return res;
}
Int gcd(Int a, Int b) { return b != 0 ? gcd(b, a % b) : a; }
Int lcm(Int a, Int b) { return a * b / gcd(a, b); }
Int extgcd(Int a, Int b, Int &x, Int &y) {
  Int g = a;
  x = 1;
  y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
struct UnionFind {
 private:
  const int n;
  int __size;
  vector<int> uf;

 public:
  UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
  int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -uf[find(x)]; }
  int size() { return __size; }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    __size--;
    if (uf[y] < uf[x]) swap(x, y);
    uf[x] += uf[y];
    uf[y] = x;
  }
};
vector<vector<int>> K;
int main() {
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  UnionFind uf(M + N + 1);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int L;
      cin >> L;
      uf.unite(M + 1 + i, L);
    }
  }
  for (int i = 1; i < N; i++) {
    if (!uf.same(M + 1 + i, M + i)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
