#include <bits/stdc++.h>
using namespace std;
struct TwoSat {
  int N;
  vector<vector<int> > gr;
  vector<int> values;
  TwoSat(int n = 0) : N(n), gr(2 * n) {}
  int add_var() {
    gr.emplace_back();
    gr.emplace_back();
    return N++;
  }
  void either(int f, int j) {
    f = (f >= 0 ? 2 * f : -1 - 2 * f);
    j = (j >= 0 ? 2 * j : -1 - 2 * j);
    gr[f ^ 1].push_back(j);
    gr[j ^ 1].push_back(f);
  }
  void set_value(int x) { either(x, x); }
  void at_most_one(const vector<int>& li) {
    if ((int)(li).size() <= 1) return;
    int cur = ~li[0];
    for (int i = 2; i < ((int)(li).size()); ++i) {
      int next = add_var();
      either(cur, ~li[i]);
      either(cur, next);
      either(~li[i], next);
      cur = ~next;
    }
    either(cur, ~li[1]);
  }
  vector<int> val, comp, z;
  int time = 0;
  int dfs(int i) {
    int low = val[i] = ++time, x;
    z.push_back(i);
    for (auto& e : gr[i])
      if (!comp[e]) low = min(low, val[e] ?: dfs(e));
    ++time;
    if (low == val[i]) do {
        x = z.back();
        z.pop_back();
        comp[x] = time;
        if (values[x >> 1] == -1) values[x >> 1] = !(x & 1);
      } while (x != i);
    return val[i] = low;
  }
  bool solve() {
    values.assign(N, -1);
    val.assign(2 * N, 0);
    comp = val;
    for (int i = 0; i < (2 * N); ++i)
      if (!comp[i]) dfs(i);
    for (int i = 0; i < (N); ++i)
      if (comp[2 * i] == comp[2 * i + 1]) return 0;
    return 1;
  }
};
int main() {
  cin.sync_with_stdio(false);
  cin.exceptions(cin.failbit);
  int N, M;
  cin >> N >> M;
  vector<vector<int> > seqs(N);
  for (int i = 0; i < (N); ++i) {
    int L;
    cin >> L;
    vector<int> seq(L);
    for (int j = 0; j < (L); ++j) cin >> seq[j], --seq[j];
    seqs[i] = move(seq);
  }
  TwoSat ts(M);
  for (int i = 0; i < (N - 1); ++i) {
    int l = min((int)(seqs[i]).size(), (int)(seqs[i + 1]).size());
    int same = 0;
    for (int j = 0; j < (l); ++j) {
      if (seqs[i][j] == seqs[i + 1][j])
        same++;
      else
        break;
    }
    if (same == l) {
      if (same == (int)(seqs[i]).size()) continue;
      cout << "No" << endl;
      exit(0);
    }
    int a = seqs[i][same];
    int b = seqs[i + 1][same];
    if (a < b) {
      ts.either(a, ~b);
    } else {
      ts.set_value(a);
      ts.set_value(~b);
    }
  }
  bool b = ts.solve();
  if (!b) {
    cout << "No" << endl;
  } else {
    vector<int> res;
    for (int i = 0; i < (M); ++i)
      if (ts.values[i]) res.push_back(i + 1);
    cout << "Yes" << endl;
    cout << (int)(res).size() << endl;
    for (auto& x : res) cout << x << ' ';
    cout << endl;
  }
  exit(0);
}
