#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100010;
vector<int> vec[Maxn], s[Maxn];
int len[Maxn];
int n, m;
int fl[Maxn];
bool v[Maxn];
int ind[Maxn];
int ans[Maxn], ansl;
int _min(int x, int y) { return x < y ? x : y; }
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) fl[i] = -1;
  for (i = 1; i <= n; i++) {
    scanf("%d", &len[i]);
    for (j = 1; j <= len[i]; j++) {
      int x;
      scanf("%d", &x);
      s[i].push_back(x);
    }
    if (i == 1) continue;
    int o = _min(len[i - 1], len[i]);
    for (j = 0; j < o; j++) {
      if (s[i - 1][j] > s[i][j]) {
        if (fl[s[i - 1][j]] == 0) {
          printf("No\n");
          return 0;
        }
        fl[s[i - 1][j]] = 1;
        if (fl[s[i][j]] == 1) {
          printf("No\n");
          return 0;
        }
        fl[s[i][j]] = 0;
        break;
      } else if (s[i - 1][j] < s[i][j]) {
        vec[s[i][j]].push_back(s[i - 1][j]);
        ind[s[i - 1][j]]++;
        break;
      }
    }
    if (j == o) {
      if (len[i - 1] > len[i]) {
        printf("No\n");
        return 0;
      }
    }
  }
  for (i = 1; i <= m; i++)
    if (fl[i] == 1) v[i] = true;
  queue<int> q;
  for (i = 1; i <= m; i++)
    if (ind[i] == 0) q.push(i);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    int sz = vec[x].size();
    for (i = 0; i < sz; i++) {
      int y = vec[x][i];
      v[y] |= v[x];
      ind[y]--;
      if (ind[y] == 0) q.push(y);
    }
  }
  for (i = 1; i <= m; i++)
    if (fl[i] == 0 && v[i] == true) {
      printf("No\n");
      return 0;
    }
  printf("Yes\n");
  for (i = 1; i <= m; i++)
    if (v[i] == true) ans[++ansl] = i;
  printf("%d\n", ansl);
  for (i = 1; i <= ansl; i++) printf("%d%c", ans[i], i == ansl ? '\n' : ' ');
  return 0;
}
