#include <bits/stdc++.h>
using namespace std;
const int N = 200020;
vector<int> v[N];
vector<int> g[N];
vector<int> topo;
int vis[N];
void dfs(int u) {
  vis[u] = 1;
  for (auto v : g[u]) {
    if (vis[v] == 1) {
      printf("No\n");
      exit(0);
    } else if (!vis[v])
      dfs(v);
  }
  vis[u] = 2;
  topo.push_back(u);
}
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      v[i].push_back(x);
    }
  }
  set<int> ans;
  for (int i = 0; i < n - 1; i++) {
    bool flag = false;
    for (int j = 0; j < min(v[i].size(), v[i + 1].size()); j++) {
      if (v[i][j] == v[i + 1][j]) continue;
      flag = true;
      g[v[i][j]].push_back(v[i + 1][j]);
      break;
    }
    if (!flag) {
      if (v[i].size() <= v[i + 1].size()) continue;
      printf("No\n");
      return 0;
    }
  }
  for (int i = 1; i <= m; i++)
    if (!vis[i]) dfs(i);
  for (int i = 0; i < topo.size(); i++) {
    int u = topo[i];
    bool flag = false;
    for (auto v : g[u]) {
      if (u < v and ans.count(v)) flag = true;
      if (u > v and ans.count(v)) {
        printf("No\n");
        exit(0);
      }
      if (u > v) flag = true;
    }
    if (flag) ans.insert(u);
  }
  printf("Yes\n");
  cout << ans.size() << endl;
  for (auto u : ans) printf("%d ", u);
  cout << endl;
  return 0;
}
