#include <bits/stdc++.h>
using namespace std;
int a[200000], q[200000], que[200000];
int yh[200000];
int ru[200000];
int dis[200000];
int vet[200000], Next[200000], hed[200000];
int num;
void add(int u, int v) {
  ++num;
  vet[num] = v;
  Next[num] = hed[u];
  hed[u] = num;
}
int main() {
  num = 0;
  int n, m;
  scanf("%d%d", &n, &m);
  int h = 0;
  q[0] = 0;
  bool flag = true;
  for (int i = 1; i <= n; ++i) {
    int l;
    scanf("%d", &l);
    for (int j = 1; j <= l; ++j) scanf("%d", &a[j]);
    if (h != 0) {
      int tot = -1;
      for (int j = 1; j <= min(h, l); ++j)
        if (a[j] != q[j]) {
          tot = j;
          break;
        }
      if (tot == -1) {
        if (h > l) {
          printf("No\n");
          return 0;
        }
      } else {
        ++ru[q[tot]];
        add(a[tot], q[tot]);
      }
    }
    h = l;
    for (int j = 1; j <= l; ++j) q[j] = a[j];
  }
  int head = 1, tail = 0;
  for (int i = 1; i <= m; ++i)
    if (ru[i] == 0) {
      ++tail;
      que[tail] = i;
      dis[i] = 0;
    }
  while (head <= tail) {
    int u = que[head];
    ++head;
    for (int i = hed[u]; i != 0; i = Next[i]) {
      --ru[vet[i]];
      if (u < vet[i])
        dis[vet[i]] = max(dis[vet[i]], dis[u] + 1);
      else
        dis[vet[i]] = max(dis[vet[i]], dis[u]);
      if (ru[vet[i]] == 0) {
        ++tail;
        que[tail] = vet[i];
      }
    }
  }
  if (tail < m) {
    printf("No\n");
    return 0;
  } else {
    int ans = 0;
    for (int i = 1; i <= m; ++i)
      if (dis[i] > 0) {
        if (dis[i] == 2) {
          printf("No\n");
          return 0;
        }
        ++ans;
        yh[ans] = i;
      }
    printf("Yes\n");
    printf("%d\n", ans);
    for (int i = 1; i <= ans; ++i) printf("%d ", yh[i]);
  }
  return 0;
}
