#include <bits/stdc++.h>
using namespace std;
const int INF = 2000 * 1000 * 1000;
const long long LLINF = 1ll << 53;
template <class T>
void relaxmax(T& r, T v) {
  r = max(r, v);
}
template <class T>
void relaxmin(T& r, T v) {
  r = min(r, v);
}
template <class T>
using max_queue = priority_queue<T>;
template <class T>
using min_queue = priority_queue<T, vector<T>, greater<T>>;
const int MAXM = 100 * 1000;
const int MAXN = 100 * 1000;
const int NONE = 0, CURR = 1, DONE = 2;
vector<int> a[MAXN];
vector<int> adj[MAXM];
int seen[MAXM];
int n, m;
vector<int> topo;
bool cycle(int u) {
  if (seen[u]) return seen[u] == CURR;
  seen[u] = CURR;
  bool ans = false;
  for (int v : adj[u]) ans = ans || cycle(v);
  seen[u] = DONE;
  topo.push_back(u);
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    int l;
    scanf("%d", &l);
    a[i].resize(l);
    for (int j = 0; j < l; ++j) {
      scanf("%d", &a[i][j]);
      a[i][j]--;
    }
  }
  for (int i = 0; i < n - 1; ++i) {
    bool diff = false;
    for (int j = 0; j < int(min(a[i].size(), a[i + 1].size())); ++j)
      if (a[i][j] != a[i + 1][j]) {
        adj[a[i][j]].push_back(a[i + 1][j]);
        diff = true;
        break;
      }
    if (!diff && a[i].size() > a[i + 1].size()) {
      puts("No");
      return 0;
    }
  }
  for (int u = 0; u < m; ++u)
    if (!seen[u] && cycle(u)) {
      puts("No");
      return 0;
    }
  vector<int> cap(m);
  for (int u : topo)
    for (int v : adj[u])
      if (u > v || cap[v]) cap[u] = true;
  for (int u = 0; u < m; ++u)
    for (int v : adj[u])
      if (u > v && cap[u] && cap[v]) {
        puts("No");
        return 0;
      }
  vector<int> ans;
  for (int u = 0; u < m; ++u)
    if (cap[u]) ans.push_back(u);
  puts("Yes");
  printf("%d\n", int(ans.size()));
  for (int u : ans) printf("%d ", u + 1);
  puts("");
  return 0;
}
