#include <bits/stdc++.h>
using namespace std;
const int N = 100002;
vector<int> w[N];
vector<int> g[N];
int cap[N];
int len[N];
bool process(int from, int to, int j) {
  if (from == to) {
    return true;
  }
  int st = from;
  int c1, c2;
  for (int i = from + 1; i <= to; i++) {
    if (len[i - 1] <= j) {
      c1 = 0;
    } else {
      c1 = w[i - 1][j];
    }
    if (len[i] <= j) {
      c2 = 0;
    } else {
      c2 = w[i][j];
    }
    if (c1 != c2) {
      if (c1 != 0) {
        g[c2].push_back(c1);
        if (!process(st, i - 1, j + 1)) {
          return false;
        }
      }
      st = i;
    }
  }
  if (c2 != 0) {
    if (!process(st, to, j + 1)) {
      return false;
    }
  }
  return true;
}
void capitalize(int v) {
  cap[v] = 1;
  for (int j = 0; j < g[v].size(); j++) {
    int next = g[v][j];
    if (cap[next] == 0) {
      capitalize(next);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", len + i);
    for (int j = 0; j < len[i]; j++) {
      int c;
      scanf("%d", &c);
      w[i].push_back(c);
    }
  }
  if (!process(0, n - 1, 0)) {
    printf("No\n");
    return 0;
  }
  if (g[0].size() > 0) {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      int next = g[i][j];
      if (cap[next] == 0) {
        if ((cap[i] == 1) || (i < next)) {
          capitalize(next);
        }
      }
    }
  }
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      int next = g[i][j];
      if (cap[i] == 1 && cap[next] == 0) {
        printf("No\n");
        return 0;
      }
      if (cap[i] == cap[next] && i <= next) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    if (cap[i]) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= m; i++) {
    if (cap[i]) {
      printf("%d ", i);
    }
  }
  printf("\n");
  return 0;
}
