#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
struct node {
  int x, c;
  node() {}
  node(int x, int c) : x(x), c(c) {}
} k;
struct E {
  int to, next;
} mem[N];
int num, n, m, l, u, b, ans, cnt;
int a[N], head[N], len[N], d[N], dis[N];
queue<node> q;
void add(int x, int y) {
  num++;
  mem[num].to = y;
  mem[num].next = head[x];
  head[x] = num;
  d[y]++;
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &len[i]);
    for (j = 1; j <= len[i]; j++) scanf("%d", &a[l + j]);
    j = 1;
    while (j <= len[i] && j <= len[i - 1] && a[l + j] == a[l - len[i - 1] + j])
      j++;
    if (j <= len[i - 1] && j > len[i]) {
      printf("No\n");
      return 0;
    }
    if (i != 1 && j <= len[i] && j <= len[i - 1])
      add(a[l + j], a[l - len[i - 1] + j]);
    l += len[i];
  }
  for (int i = 1; i <= m; i++)
    if (!d[i]) q.push(node(i, 0)), cnt++;
  while (!q.empty()) {
    k = q.front();
    q.pop();
    if (k.c == 2) {
      printf("No\n");
      return 0;
    }
    for (int j = head[k.x]; j; j = mem[j].next) {
      u = mem[j].to;
      d[u]--;
      b = k.x < u;
      if (b || dis[k.x]) dis[u] = 1;
      if (!d[u]) q.push(node(u, k.c + b)), cnt++;
    }
  }
  if (cnt < m) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  for (i = 1; i <= m; i++) ans += dis[i];
  printf("%d\n", ans);
  for (int i = 1; i <= m; i++)
    if (dis[i]) printf("%d ", i);
  return 0;
}
