#include <bits/stdc++.h>
using namespace std;
int n, m, l[100010], sz, first[200010], nxt[200010], tail[200010], dep[200010],
    scc[200010], cc[200010], dfn[200010], low[200010], lv, stk[200010],
    ans[200010];
vector<int> str[100010];
void addedge(int u, int v);
void dfs(int u);
int main() {
  scanf("%d%d", &n, &m);
  int i, j, x;
  for (i = 1; i <= n; i++) {
    scanf("%d", &l[i]);
    str[i].clear();
    for (j = 1; j <= l[i]; j++) {
      scanf("%d", &x);
      str[i].push_back(x);
    }
  }
  memset(first, 0, sizeof(first));
  for (sz = 0, i = 1; i < n; i++) {
    for (j = 1; j <= min(l[i], l[i + 1]); j++)
      if (str[i][j - 1] != str[i + 1][j - 1]) break;
    if (j > l[i])
      continue;
    else if (j > l[i + 1]) {
      puts("No");
      return 0;
    }
    if (str[i][j - 1] < str[i + 1][j - 1]) {
      addedge(str[i][j - 1] + m, str[i + 1][j - 1] + m);
      addedge(str[i + 1][j - 1], str[i][j - 1]);
    } else {
      addedge(str[i][j - 1] + m, str[i][j - 1]);
      addedge(str[i + 1][j - 1], str[i + 1][j - 1] + m);
    }
  }
  memset(dep, 0, sizeof(dep));
  for (dfn[0] = scc[0] = cc[0] = 0, lv = 0, i = 1; i <= m * 2; i++)
    if (!dep[i]) {
      ++cc[0];
      dep[i] = 1;
      dfs(i);
    }
  int cnt = 0;
  for (i = 1; i <= m; i++)
    if (scc[i] == scc[i + m]) {
      puts("No");
      return 0;
    } else if (cc[i] < cc[i + m] || cc[i] == cc[i + m] && dep[i] > dep[i + m])
      ans[++cnt] = i;
  puts("Yes");
  printf("%d\n", cnt);
  for (i = 1; i <= cnt; i++) printf("%d%c", ans[i], i < cnt ? ' ' : '\n');
  return 0;
}
void addedge(int u, int v) {
  tail[++sz] = v;
  nxt[sz] = first[u];
  first[u] = sz;
}
void dfs(int u) {
  low[u] = dfn[u] = ++dfn[0];
  scc[u] = -1;
  cc[u] = cc[0];
  stk[++lv] = u;
  int v, e;
  for (e = first[u]; e; e = nxt[e]) {
    v = tail[e];
    if (!dep[v]) {
      dep[v] = dep[u] + 1;
      dfs(v);
      low[u] = min(low[u], low[v]);
    } else if (scc[v] == -1)
      low[u] = min(low[u], low[v]);
  }
  if (low[u] == dfn[u]) {
    scc[0]++;
    while (stk[lv] != u) scc[stk[lv--]] = scc[0];
    scc[stk[lv--]] = scc[0];
  }
}
