#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
bool MinPlace(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool MaxPlace(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (int i = 0; i < (int)v.size(); i++) {
    out << v[i];
    if (i != (int)v.size() - 1) out << ", ";
  }
  out << "]";
  return out;
}
class TwoSatSolver {
 public:
  int n;
  vector<vector<int>> g, gt;
  vector<bool> used;
  vector<int> order, comp;
  vector<bool> assignment;
  TwoSatSolver(int _n) : n(2 * max(_n, 1)) {
    g.resize(n);
    gt.resize(n);
  };
  void add_edge(int u, bool ut, int v, bool vt) {
    int uu = 2 * u + int(ut), nuu = 2 * u + int(!ut), vv = 2 * v + int(vt),
        nvv = 2 * v + int(!vt);
    g[uu].push_back(vv);
    gt[vv].push_back(uu);
    g[nvv].push_back(nuu);
    gt[nuu].push_back(nvv);
  }
  void dfs1(int v) {
    used[v] = true;
    for (int u : g[v]) {
      if (!used[u]) dfs1(u);
    }
    order.push_back(v);
  }
  void dfs2(int v, int cl) {
    comp[v] = cl;
    for (int u : gt[v]) {
      if (comp[u] == -1) dfs2(u, cl);
    }
  }
  bool solve_2SAT() {
    used.assign(n, false);
    for (int i = 0; i < n; ++i) {
      if (!used[i]) dfs1(i);
    }
    comp.assign(n, -1);
    for (int i = 0, j = 0; i < n; ++i) {
      int v = order[n - i - 1];
      if (comp[v] == -1) dfs2(v, j++);
    }
    assignment.assign(n / 2, false);
    for (int i = 0; i < n; i += 2) {
      if (comp[i] == comp[i + 1]) return false;
      assignment[i / 2] = (comp[i] > comp[i + 1]);
    }
    return true;
  }
  vector<bool> getAsgn() { return assignment; }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  TwoSatSolver sat(m);
  vector<vector<int>> arr(n, vector<int>());
  for (int i = 0; i < n; i++) {
    int len;
    cin >> len;
    arr[i].resize(len);
    bool done = !i;
    for (int j = 0; j < len; j++) {
      cin >> arr[i][j];
      --arr[i][j];
      if (!done and arr[i - 1].size() > j and arr[i - 1][j] != arr[i][j]) {
        if (arr[i - 1][j] < arr[i][j]) {
          sat.add_edge(arr[i][j], 0, arr[i - 1][j], 0);
        } else {
          sat.add_edge(arr[i - 1][j], 1, arr[i - 1][j], 0);
          sat.add_edge(arr[i][j], 0, arr[i][j], 1);
        }
        done = true;
      }
    }
    if (!done and arr[i].size() < arr[i - 1].size()) {
      cout << "No\n";
      return 0;
    }
  }
  if (sat.solve_2SAT()) {
    cout << "Yes\n";
    int cnt = 0;
    vector<bool> asgn = sat.getAsgn();
    for (int i = 0; i < m; i++) cnt += asgn[i];
    cout << cnt << "\n";
    for (int i = 0; i < m; i++)
      if (asgn[i]) cout << (i + 1) << " ";
  } else
    cout << "No\n";
}
