#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int n, m, l[MAXN], x, in[MAXN], red[MAXN];
vector<int> G[MAXN], w[MAXN], tp, sol;
bool bio[MAXN];
void f(int x) {
  bio[x] = 1;
  for (int i : G[x]) {
    if (!bio[i]) f(i);
    if (red[x] > red[i]) {
      red[x] -= MAXN;
      sol.push_back(x);
    }
  }
}
bool check(int x) {
  for (int i : G[x]) {
    if (red[x] > red[i]) return 1;
  }
  return 0;
}
int main() {
  for (int i = 0; i < MAXN; ++i) {
    red[i] = i;
  }
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", l + i);
    for (int j = 0; j < l[i]; ++j) {
      scanf("%d", &x);
      x--;
      w[i].push_back(x);
    }
  }
  for (int i = 0; i < n - 1; ++i) {
    bool prefix = 1;
    for (int j = 0; j < (int)min(w[i].size(), w[i + 1].size()); ++j) {
      if (w[i][j] != w[i + 1][j]) {
        prefix = 0;
        G[w[i][j]].push_back(w[i + 1][j]);
        in[w[i + 1][j]]++;
        break;
      }
    }
    if (prefix && w[i + 1].size() < w[i].size()) {
      printf("No\n");
      return 0;
    }
  }
  for (int i = 0; i < m; ++i) {
    if (!bio[i]) {
      f(i);
    }
  }
  for (int i = 0; i < m; ++i) {
    if (check(i)) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n%d\n", (int)sol.size());
  for (int i : sol) {
    printf("%d ", i + 1);
  }
  return 0;
}
