#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
template <class T>
inline bool RD(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1, ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void PT(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) PT(x / 10);
  putchar(x % 10 + '0');
}
const int N = 2e5 + 100;
vector<int> g[N];
inline void add_edge(int u, int v) { g[u].push_back(v); }
int dfn[N], low[N], col[N], tmp[N], sta[N], top;
int indx, scc;
void tarjan(int u) {
  low[u] = dfn[u] = ++indx;
  tmp[u] = 1;
  sta[++top] = u;
  int sz = g[u].size();
  for (int i = 0; i < sz; i++) {
    int v = g[u][i];
    if (tmp[v] == 0) tarjan(v);
    if (tmp[v] == 1) low[u] = min(low[u], low[v]);
  }
  if (dfn[u] == low[u]) {
    scc++;
    int v;
    do {
      v = sta[top--];
      tmp[v] = 2;
      col[v] = scc;
    } while (v != u);
  }
}
vector<int> vec[N];
vector<int> G[N];
int deg[N];
bool print[N];
vector<int> book[N];
int que[N], head, tail;
vector<int> res;
int main() {
  int n, m;
  cin >> n >> m;
  bool flag = false;
  for (int i = 1; i <= n; i++) {
    int k, num;
    scanf("%d", &k);
    bool f = true;
    for (int j = 0; j < k; j++) {
      scanf("%d", &num);
      vec[i].push_back(num);
      if (i != 1 && f && vec[i - 1].size() >= j + 1) {
        if (vec[i - 1][j] > vec[i][j]) {
          add_edge(vec[i - 1][j] << 1, (vec[i - 1][j] << 1) ^ 1);
          add_edge((vec[i][j] << 1) ^ 1, vec[i][j] << 1);
          f = false;
        } else if (f && vec[i - 1][j] < vec[i][j]) {
          add_edge(vec[i - 1][j] << 1, vec[i][j] << 1);
          add_edge((vec[i][j] << 1) ^ 1, (vec[i - 1][j] << 1) ^ 1);
          f = false;
        }
      }
    }
    if (i != 1 && f && (int((vec[i - 1]).size())) > (int((vec[i]).size())))
      flag = true;
  }
  if (flag) return puts("No") * 0;
  for (int i = 2; i < 2 * (m + 1); i++)
    if (dfn[i] == 0) tarjan(i);
  for (int i = 2; i < 2 * (m + 1); i++) {
    book[col[i]].push_back(col[i ^ 1]);
    if (col[i] == col[i ^ 1]) {
      puts("No");
      return 0;
    }
  }
  for (int u = 2; u < 2 * (m + 1); u++) {
    for (int j = 0; j < (int((g[u]).size())); j++) {
      int v = g[u][j];
      if (col[u] == col[v]) continue;
      deg[col[u]]++;
      G[col[v]].push_back(col[u]);
    }
  }
  for (int i = 1; i <= scc; i++)
    if (deg[i] == 0) que[tail++] = i;
  while (head < tail) {
    int u = que[head++];
    if (print[u] == 0) {
      for (int v : book[u]) print[v] = 1;
    }
    for (int v : G[u])
      if (--deg[v] == 0) que[tail++] = v;
  }
  for (int i = 1; i <= m; i++) {
    if (print[col[(i << 1) ^ 1]] == 0) res.push_back(i);
  }
  puts("Yes");
  printf("%d\n", (int((res).size())));
  for (int v : res) printf("%d\n", v);
}
