#include <bits/stdc++.h>
using namespace std;
template <typename T>
void resize(int n, vector<T> &u) {
  u.resize(n);
}
template <typename Head, typename... Tail>
void resize(int n, Head &H, Tail &...T) {
  resize(n, H);
  resize(n, T...);
}
class TwoSAT {
 public:
  ;
  vector<vector<int>> E, G;
  vector<int> disc, low, comp;
  vector<bool> in, sol;
  int sz, tid = 0, csz = 0;
  stack<int> st;
  vector<int> exp, lsz;
  TwoSAT(int n) : sz((n << 1) - 1) {
    resize(n << 1, E, disc, low, comp, in, sol);
  }
  void imply(int u, int v) { E[u].push_back(v); }
  void Trajan(int u) {
    disc[u] = low[u] = ++tid;
    st.push(u);
    in[u] = 1;
    for (int i = 0; i < (int)E[u].size(); i++) {
      int v = E[u][i];
      if (!disc[v]) {
        Trajan(v);
        low[u] = min(low[u], low[v]);
      } else if (in[v])
        low[u] = min(low[u], disc[v]);
    }
    if (disc[u] == low[u]) {
      int v;
      csz++;
      do {
        v = st.top();
        comp[v] = csz;
        st.pop();
        in[v] = 0;
      } while (v != u);
    }
  }
  bool Check() {
    for (int i = 0; i <= sz; i++)
      if (!disc[i]) Trajan(i);
    for (int i = 0; i <= sz; i++)
      if (comp[i] == comp[i ^ 1]) return false;
    return true;
  }
  void Solve() {
    int i, j;
    G.resize(csz + 1);
    lsz.resize(csz + 1);
    exp.resize(csz + 1);
    for (i = 0; i <= sz; i++) {
      for (j = 0; j < (int)E[i].size(); j++) {
        int v = E[i][j];
        if (comp[i] != comp[v]) G[comp[i]].push_back(comp[v]), lsz[comp[v]]++;
      }
    }
    queue<int> q;
    for (i = 1; i <= csz; i++)
      if (!lsz[i]) q.push(i);
    int tm = 0;
    while (q.size()) {
      int x = q.front();
      q.pop();
      exp[x] = ++tm;
      for (i = 0; i < (int)G[x].size(); i++) {
        int y = G[x][i];
        lsz[y]--;
        if (!lsz[y]) q.push(y);
      }
    }
    for (i = 0; i <= sz; i += 2)
      if (exp[comp[i ^ 1]] > exp[comp[i]]) sol[i >> 1] = 1;
  }
};
int n, m;
int main() {
  cin >> n >> m;
  vector<vector<int>> p(n);
  for (int i = 0; i < n; i++) {
    int sz;
    scanf("%d", &sz);
    p[i].resize(sz);
    for (int j = 0; j < sz; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  TwoSAT st(m);
  for (int i = 0; i < n - 1; i++) {
    int a = p[i].size(), b = p[i + 1].size();
    int pos = -1;
    for (int j = 0; j < min(a, b); j++) {
      if (p[i][j] != p[i + 1][j]) {
        pos = j;
        break;
      }
    }
    if (pos == -1) {
      if (a > b) {
        cout << "No";
        return 0;
      }
      continue;
    }
    int x = p[i][pos] - 1, y = p[i + 1][pos] - 1;
    if (x > y) {
      st.imply(2 * y, 2 * y + 1);
      st.imply(2 * x + 1, 2 * x);
    } else {
      st.imply(2 * y, 2 * x);
      st.imply(2 * x + 1, 2 * y + 1);
    }
  }
  if (st.Check()) {
    cout << "Yes" << endl;
    st.Solve();
    vector<int> res;
    for (int i = 0; i < m; i++) {
      if (!st.sol[i]) {
        res.push_back(i);
      }
    }
    printf("%d\n", res.size());
    for (auto i : res) printf("%d ", i + 1);
  } else {
    cout << "No";
  }
  return 0;
}
