#include <bits/stdc++.h>
using namespace std;
int Next[400010], head[400010], q[400010], vet[400010];
int len[10000], x[3][100010], num, du[400010], flag[400010], ans[400010];
void add(int u, int v) {
  Next[++num] = head[u];
  head[u] = num;
  vet[num] = v;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%d", &len[1]);
  for (int i = 1; i <= len[1]; i++) scanf("%d", &x[1][i]);
  for (int i = 2; i <= n; i++) {
    int now = i & 1, pre = (i - 1) & 1;
    scanf("%d", &len[now]);
    for (int j = 1; j <= len[now]; j++) scanf("%d", &x[now][j]);
    int le = min(len[pre], len[now]);
    for (int j = 1; j <= le; j++) {
      if (x[pre][j] == x[now][j]) continue;
      add(x[now][j], x[pre][j]);
      goto OK;
    }
    if (len[now] < len[pre]) {
      puts("No");
      return 0;
    }
  OK:;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = head[i]; j; j = Next[j]) {
      int v = vet[j];
      du[v]++;
    }
  }
  int he = 1, ta = 0;
  for (int i = 1; i <= m; i++)
    if (!du[i]) q[++ta] = i;
  memset(flag, 0, sizeof(flag));
  while (he <= ta) {
    int u = q[he];
    for (int i = head[u]; i; i = Next[i]) {
      int v = vet[i];
      du[v]--;
      if (v > u) {
        if (flag[u]) {
          puts("No");
          return 0;
        } else
          flag[v] = 1;
      } else
        flag[v] = flag[u];
      if (!du[v]) q[++ta] = v;
    }
    he++;
  }
  if (ta < m) {
    printf("No");
    return 0;
  }
  int cnt = 0;
  for (int i = 1; i <= m; i++)
    if (flag[i]) ans[++cnt] = i;
  printf("Yes\n");
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) printf("%d ", ans[i]);
  return 0;
}
