#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
struct node {
  int to, nxt;
} g[maxn * 2];
int pr[maxn], a[maxn], h[maxn], dfn[maxn], low[maxn], fa[maxn], cnt, fc;
bool vis[maxn];
stack<int> s;
void vAdd(int u, int v) {
  cnt++;
  g[cnt].to = v;
  g[cnt].nxt = h[u];
  h[u] = cnt;
}
void tarjan(int id) {
  low[id] = dfn[id] = ++cnt;
  vis[id] = true;
  s.push(id);
  int i, nxt;
  for (i = h[id]; i; i = g[i].nxt) {
    nxt = g[i].to;
    if (!dfn[nxt]) {
      tarjan(nxt);
      low[id] = min(low[id], low[nxt]);
    } else if (vis[nxt])
      low[id] = min(low[id], dfn[nxt]);
  }
  if (low[id] == dfn[id]) {
    fc++;
    do {
      i = s.top();
      s.pop();
      vis[i] = false;
      fa[i] = fc;
    } while (i != id);
  }
}
int main() {
  int i, j, n, m, l, pl = 0, nAns = 0;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &l);
    for (j = 1; j <= l; j++) scanf("%d", &a[j]);
    for (j = 1; j <= min(pl, l); j++) {
      if (pr[j] < a[j]) {
        vAdd(a[j], pr[j]);
        vAdd(pr[j] + m, a[j] + m);
        break;
      } else if (pr[j] > a[j]) {
        vAdd(a[j], a[j] + m);
        vAdd(pr[j] + m, pr[j]);
        break;
      } else if (j == min(pl, l) && pl > l) {
        printf("No\n");
        return 0;
      }
    }
    pl = l;
    for (j = 1; j <= l; j++) pr[j] = a[j];
  }
  cnt = 0;
  for (i = 1; i <= m * 2; i++)
    if (!dfn[i]) tarjan(i);
  for (i = 1; i <= m; i++) {
    if (fa[i] == fa[i + m]) {
      printf("No\n");
      return 0;
    }
    if (fa[i] < fa[i + m]) nAns++;
  }
  printf("Yes\n%d\n", nAns);
  for (i = 1; i <= m; i++)
    if (fa[i] < fa[i + m]) printf("%d ", i);
  printf("\n");
  return 0;
}
