#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct SAT {
  vector<int> g[2 * N];
  vector<int> gr[2 * N];
  bool vis[2 * N];
  vector<int> order;
  int comp[2 * N], SCCcnt;
  int ans[N];
  int n;
  int neg(int x) { return x >= n ? x - n : x + n; }
  void addor(int a, int b) {
    g[neg(a)].push_back(b);
    g[neg(b)].push_back(a);
    gr[b].push_back(neg(a));
    gr[a].push_back(neg(b));
  }
  void dfs1(int v) {
    vis[v] = true;
    for (auto u : g[v])
      if (!vis[u]) dfs1(u);
    order.push_back(v);
  }
  void dfs2(int v, int c) {
    comp[v] = c;
    for (auto u : gr[v])
      if (comp[u] == -1) dfs2(u, c);
  }
  bool sat() {
    SCCcnt = 0;
    memset(vis, 0, sizeof vis);
    for (int i = 0; i < n; i++) {
      if (!vis[i]) dfs1(i);
      if (!vis[neg(i)]) dfs1(neg(i));
    }
    memset(comp, -1, sizeof comp);
    for (int i = 0; i < 2 * n; i++) {
      int v = order[2 * n - 1 - i];
      if (comp[v] == -1) dfs2(v, SCCcnt++);
    }
    for (int i = 0; i < n; i++)
      if (comp[i] == comp[neg(i)]) return false;
    for (int i = 0; i < n; i++) ans[i] = comp[i] > comp[neg(i)] ? 1 : 0;
    return true;
  }
} sat;
vector<int> a[N];
vector<int> chars;
int main() {
  bool ok = true;
  int n, m;
  scanf("%d %d", &n, &m);
  sat.n = m;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a[i].reserve(x);
    while (x--) {
      int y;
      scanf("%d", &y);
      y--;
      a[i].emplace_back(y);
    }
  }
  for (int i = 1; i < n; i++) {
    bool dif = false;
    for (int j = 0; j < (int)min(a[i].size(), a[i - 1].size()); j++) {
      if (a[i - 1][j] == a[i][j]) {
        continue;
      } else if (a[i - 1][j] < a[i][j]) {
        dif = true;
        sat.addor(sat.neg(a[i][j]), a[i - 1][j]);
        break;
      } else {
        dif = true;
        sat.addor(a[i - 1][j], a[i - 1][j]);
        sat.addor(sat.neg(a[i][j]), sat.neg(a[i][j]));
        break;
      }
    }
    if (!dif) ok = ok && (a[i - 1].size() <= a[i].size());
  }
  ok = ok && sat.sat();
  if (!ok) return puts("No"), 0;
  puts("Yes");
  vector<int> res;
  for (int i = 0; i < m; i++)
    if (sat.ans[i]) res.emplace_back(i + 1);
  printf("%d\n", int(res.size()));
  for (auto x : res) printf("%d ", x);
}
