#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const long long MOD = 1e9 + 7;
const auto INF = 0x3f3f3f3f;
int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return x < 0 ? -1 : 1;
}
const int MAXN = 2e5 + 5;
int s[2][MAXN], len[2];
int low[MAXN], dfn[MAXN], sccno[MAXN], dfs_clock, scc_cnt;
int ans[MAXN];
stack<int> S;
vector<int> G[MAXN];
void AddEdge(int x, int valx, int y, int valy) {
  x = x * 2 + valx;
  y = y * 2 + valy;
  G[x].push_back(y);
}
void dfs(int u) {
  low[u] = dfn[u] = ++dfs_clock;
  S.push(u);
  for (int v : G[u]) {
    if (!dfn[v]) {
      dfs(v);
      low[u] = min(low[u], low[v]);
    } else if (!sccno[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    scc_cnt++;
    for (;;) {
      int x = S.top();
      S.pop();
      sccno[x] = scc_cnt;
      if (x == u) break;
    }
  }
}
int main() {
  int n, m, x, v = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &len[v]);
    for (int j = 0; j < len[v]; j++) scanf("%d", &s[v][j]);
    if (i) {
      int l1 = len[v ^ 1], l2 = len[v];
      int l = min(l1, l2);
      bool f = 0;
      for (int j = 0; j < l; j++) {
        int c1 = s[v ^ 1][j] - 1, c2 = s[v][j] - 1;
        if (c1 == c2) continue;
        if (c1 < c2) {
          AddEdge(c2, 1, c1, 1);
          AddEdge(c1, 0, c2, 0);
        } else {
          AddEdge(c1, 0, c1, 1);
          AddEdge(c2, 1, c2, 0);
        }
        f = 1;
        break;
      }
      if (!f && l1 > l2) {
        puts("No");
        return 0;
      }
    }
    v ^= 1;
  }
  for (int i = 0; i < 2 * m; i++)
    if (!dfn[i]) dfs(i);
  int cnt = 0;
  for (int i = 0; i < 2 * m; i += 2) {
    if (sccno[i] == sccno[i + 1]) {
      puts("No");
      return 0;
    }
    if (sccno[i] > sccno[i + 1]) {
      ans[i >> 1] = 1;
      cnt++;
    }
  }
  puts("Yes");
  printf("%d\n", cnt);
  for (int i = 0; i < m; i++) {
    if (ans[i]) printf("%d ", i + 1);
  }
  return 0;
}
