#include <bits/stdc++.h>
using namespace std;
int n, m, a[100010], b[100010], ind, must[100010], mustnot[100010], vis[100010],
    phele[100010];
vector<int> g[100010];
bool flag;
vector<int> ans;
void dfs(int node) {
  vis[node] = 1;
  if (!phele[node]) ans.push_back(node);
  phele[node] = 1;
  if (mustnot[node]) flag = 1;
  for (const int &it : g[node]) {
    if (vis[it]) continue;
    dfs(it);
  }
}
int main(int argc, char const *argv[]) {
  ans.clear();
  memset(phele, 0, sizeof(phele));
  memset(vis, 0, sizeof(vis));
  memset(must, 0, sizeof(must));
  memset(mustnot, 0, sizeof(mustnot));
  flag = 0;
  for (int i = 0; i < 100010; i++) g[i].clear();
  scanf("%d%d", &n, &m);
  scanf("%d", a);
  for (int i = 1; i <= a[0]; i++) scanf("%d", a + i);
  for (int i = 1; i < n; i++) {
    ind = 1;
    scanf("%d", b);
    for (int j = 1; j <= b[0]; j++) scanf("%d", b + j);
    while (ind <= a[0] && ind <= b[0] && a[ind] == b[ind]) ind++;
    if (!(ind > a[0] && ind > b[0]) && ind > b[0]) {
      printf("No\n");
      return 0;
    } else if (!(ind > a[0] && ind > b[0])) {
      if (ind <= a[0]) {
        if (a[ind] > b[ind]) {
          if (mustnot[a[ind]] || must[b[ind]]) {
            printf("No\n");
            return 0;
          }
          must[a[ind]] = 1;
          mustnot[b[ind]] = 1;
        } else {
          g[b[ind]].push_back(a[ind]);
        }
      }
    }
    for (int j = 0; j <= b[0]; j++) {
      a[j] = b[j];
    }
  }
  for (int i = 1; i <= m; i++) {
    if (must[i]) dfs(i);
  }
  if (flag)
    printf("No\n");
  else {
    printf("Yes\n");
    printf("%d\n", (int)ans.size());
    for (const int &it : ans) printf("%d ", it);
    printf("\n");
  }
  return 0;
}
