#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 2e5 + 10;
int n, m;
int l[kMaxN];
vector<int> s[kMaxN];
class TarjanSCC {
  int n;
  vector<vector<int>> G, sccs;
  vector<int> wh, ind, lowlink;
  stack<int> st;
  vector<bool> inStack;
  int indCount;
  void Dfs(int x) {
    ind[x] = ++indCount;
    lowlink[x] = ind[x];
    st.push(x);
    inStack[x] = true;
    for (auto y : G[x]) {
      if (!ind[y] || inStack[y]) {
        if (!ind[y]) Dfs(y);
        lowlink[x] = min(lowlink[x], lowlink[y]);
      }
    }
    if (lowlink[x] == ind[x]) {
      vector<int> scc;
      int y;
      do {
        y = st.top();
        st.pop();
        inStack[y] = false;
        wh[y] = sccs.size();
        scc.push_back(y);
      } while (y != x);
      sccs.push_back(scc);
    }
  }

 public:
  TarjanSCC(const vector<vector<int>>& G) : G(G) {
    n = G.size() - 1;
    wh = ind = lowlink = vector<int>(n + 1);
    inStack = vector<bool>(n + 1);
    indCount = 0;
    for (int i = 1; i <= n; ++i) {
      if (!ind[i]) {
        Dfs(i);
      }
    }
  }
  vector<vector<int>> GetSCCs() { return sccs; }
  vector<int> GetWh() { return wh; }
};
class TwoSAT {
  int n;
  vector<vector<int>> G;
  int ind(int x) { return x > 0 ? ((x << 1) - 1) : (((-x) << 1)); }
  int op(int x) { return (x & 1) ? x + 1 : x - 1; }
  void Resize(int n) {
    if (n > this->n) {
      this->n = n;
      G.resize(max(ind(n), ind(-n)) + 1);
    }
  }
  void AddEdge(int x, int y) {
    G[x].push_back(y);
    G[op(y)].push_back(op(x));
  }

 public:
  void Implication(int x, int y) {
    Resize(max(abs(x), abs(y)));
    AddEdge(ind(x), ind(y));
  }
  void Disjunction(int x, int y) {
    Resize(max(abs(x), abs(y)));
    AddEdge(ind(-x), ind(y));
  }
  void SetToZero(int x) {
    Resize(abs(x));
    AddEdge(ind(x), op(ind(x)));
  }
  void SetToOne(int x) {
    Resize(abs(x));
    AddEdge(op(ind(x)), ind(x));
  }
  TwoSAT(int n = 0) : n(n) { G.resize(2 * n + 3); }
  vector<bool> Solve() {
    TarjanSCC sccSolver(G);
    auto wh = sccSolver.GetWh();
    for (int i = 1; i <= n; ++i) {
      if (wh[ind(i)] == wh[op(ind(i))]) return {};
    }
    vector<bool> sol(n + 1);
    for (int i = 1; i <= n; ++i) {
      sol[i] = (wh[ind(i)] > wh[op(ind(i))] ? 0 : 1);
    }
    return sol;
  }
};
void Solve() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &l[i]);
    s[i].resize(l[i] + 1);
    for (int j = 1; j <= l[i]; ++j) {
      scanf("%d", &s[i][j]);
    }
  }
  TwoSAT solver(m);
  for (int i = 1; i < n; ++i) {
    bool diff = false;
    for (int j = 1; j <= l[i] && j <= l[i + 1]; ++j) {
      if (s[i][j] != s[i + 1][j]) {
        diff = true;
        if (s[i][j] <= s[i + 1][j]) {
          solver.Implication(s[i + 1][j], s[i][j]);
        } else {
          solver.SetToOne(s[i][j]);
          solver.SetToZero(s[i + 1][j]);
        }
        break;
      }
    }
    if (!diff) {
      if (l[i] > l[i + 1]) {
        cout << "No\n";
        return;
      }
    }
  }
  auto sol = solver.Solve();
  if (sol.empty()) {
    cout << "No\n";
  } else {
    vector<int> ans;
    for (int i = 1; i <= m; ++i) {
      if (sol[i]) {
        ans.push_back(i);
      }
    }
    cout << "Yes\n";
    cout << ans.size() << "\n";
    for (auto el : ans) {
      cout << el << " ";
    }
  }
}
int main() {
  int tests = 1;
  for (; tests; --tests) {
    Solve();
  }
}
