#include <bits/stdc++.h>
using namespace std;
int flag[100005];
int ok, a[100005], b[100005], vis[100005];
vector<int> G[100005];
void Sech(int u, int p) {
  int i, v;
  vis[u] = 1;
  if (flag[u] == 1) ok = -1;
  flag[u] = -1;
  for (i = 0; i < G[u].size(); i++) {
    v = G[u][i];
    if (v == p || vis[v]) continue;
    Sech(v, u);
  }
}
int main(void) {
  ok = 1;
  int n, m, i, j, len2, len1, ans;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    if (i == 1) {
      scanf("%d", &len2);
      for (j = 1; j <= len2; j++) scanf("%d", &b[j]);
      continue;
    }
    for (j = 1; j <= len2; j++) a[j] = b[j];
    len1 = len2;
    scanf("%d", &len2);
    for (j = 1; j <= len2; j++) scanf("%d", &b[j]);
    for (j = 1; j <= min(len1, len2); j++) {
      if (a[j] < b[j]) {
        G[b[j]].push_back(a[j]);
        break;
      } else if (a[j] > b[j]) {
        if (flag[a[j]] == 1 || flag[b[j]] == -1) ok = -1;
        flag[a[j]] = -1, flag[b[j]] = 1;
        break;
      }
    }
    if (len1 > len2 && j == len2 + 1) {
      printf("No\n");
      return 0;
    }
  }
  if (ok == -1) {
    printf("No\n");
    return 0;
  }
  for (i = 1; i <= m; i++) {
    if (vis[i] == 0 && flag[i] == -1) Sech(i, -1);
    if (ok == -1) break;
  }
  if (ok == -1) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  ans = 0;
  for (i = 1; i <= m; i++) {
    if (flag[i] == -1) ans++;
  }
  printf("%d\n", ans);
  for (i = 1; i <= m; i++) {
    if (flag[i] == -1) printf("%d ", i);
  }
  if (ans != 0) printf("\n");
  return 0;
}
