#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool uin(T &a, T b) {
  return a > b && (a = b, true);
}
template <class T>
inline bool uax(T &a, T b) {
  return a < b && (a = b, true);
}
class CNationalProperty {
 public:
  void solve_case(istream &cin, ostream &cout) {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> S(N), G(M);
    for (int l, i = 0; i < N; ++i) {
      cin >> l;
      S[i].resize(l);
      for (int j = 0; j < l; ++j) {
        cin >> S[i][j];
        --S[i][j];
      }
    }
    vector<bool> pls_cap(M, false), don_cap(M, false);
    bool is_possible = true;
    for (int i = 0; i < N - 1 && is_possible; ++i) {
      for (int j = 0; j < (int)S[i].size() && is_possible; ++j) {
        int cur = S[i][j], nxt = -1;
        if (S[i + 1].size() > j) nxt = S[i + 1][j];
        if (cur == nxt) continue;
        if (cur > nxt) {
          if (nxt == -1) {
            is_possible = false;
            break;
          }
          pls_cap[cur] = true;
          don_cap[nxt] = true;
        } else {
          G[nxt].push_back(cur);
        }
        break;
      }
    }
    vector<bool> vis(M, false);
    vector<int> ans;
    function<void(int)> dfs = [&](int v) {
      vis[v] = true;
      ans.push_back(v);
      if (don_cap[v]) is_possible = false;
      for (int ch : G[v])
        if (!vis[ch]) dfs(ch);
    };
    for (int i = 0; i < M; ++i)
      if (!vis[i] && pls_cap[i]) dfs(i);
    if (!is_possible) {
      cout << "No" << '\n';
      return;
    }
    cout << "Yes" << '\n' << (int)ans.size() << '\n';
    for (int v : ans) cout << v + 1 << ' ';
    cout << '\n';
  }
  void solve(istream &cin, ostream &cout) {
    int tt = 1;
    while (tt--) solve_case(cin, cout);
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  CNationalProperty solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
