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