#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
using ll = long long;
using ld = long double;
constexpr int nax = 1000 * 1000 + 105;
constexpr int infty = 1000 * 1000 * 1000 + 5;
constexpr int mod = 1000 * 1000 * 1000 + 7;
bool zam[nax];
vector<int> wynik[nax];
bool Ok(vector<int>& a, vector<int>& b) {
  const int m = min(a.size(), b.size());
  for (int i = 0; i < m; i++) {
    if (a[i] != b[i]) {
      if (a[i] < b[i]) {
        return true;
      } else {
        assert(a[i] > b[i]);
        return false;
      }
    }
  }
  return a.size() <= b.size();
}
void Ogarnij(vector<int>& a, vector<int>& b) {
  const int m = min(a.size(), b.size());
  for (int i = 0; i < m; i++) {
    if (a[i] != b[i]) {
      if (a[i] < b[i]) {
        wynik[b[i]].push_back(a[i]);
        return;
      } else {
        assert(a[i] > b[i]);
        zam[a[i]] = true;
        return;
      }
    }
  }
}
vector<vector<int>> v;
void Popraw(int w) {
  for (int x : wynik[w]) {
    if (!zam[x]) {
      zam[x] = true;
      Popraw(x);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int l;
    scanf("%d", &l);
    v.emplace_back();
    while (l--) {
      int a;
      scanf("%d", &a);
      v.back().push_back(a);
    }
  }
  for (int i = 1; i < n; i++) {
    Ogarnij(v[i - 1], v[i]);
  }
  for (int i = 1; i <= m; i++) {
    if (zam[i]) {
      Popraw(i);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int& x : v[i]) {
      if (zam[x]) x -= 1000 * 1000;
    }
  }
  for (int i = 1; i < n; i++) {
    if (!Ok(v[i - 1], v[i])) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  set<int> s;
  for (int i = 1; i <= m; i++)
    if (zam[i]) s.insert(i);
  printf("%d\n", (int)s.size());
  for (int x : s) printf("%d ", x);
  printf("\n");
  return 0;
}
