#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 100005;
vector<int> adj[N];
vector<int> caps;
bool cap[N];
vector<vector<int> > v;
int n, m;
void dfs(int v) {
  cap[v] = true;
  for (auto u : adj[v]) {
    if (!cap[u]) dfs(u);
  }
}
int main() {
  cin >> n >> m;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    int sz;
    cin >> sz;
    v[i].resize(sz);
    for (int j = 0; j < sz; j++) cin >> v[i][j];
  }
  int i = 0;
  while (i + 1 < n) {
    int j = 0, k = 0;
    while (j < v[i].size() && k < v[i + 1].size()) {
      if (v[i][j] != v[i + 1][k]) break;
      j++;
      k++;
    }
    if (k == v[i + 1].size() && (j != v[i].size())) {
      cout << "No" << endl;
      return 0;
    }
    if (j != v[i].size()) {
      if (v[i][j] > v[i + 1][k]) {
        caps.push_back(v[i][j]);
      } else {
        adj[v[i + 1][k]].push_back(v[i][j]);
      }
    }
    i++;
  }
  for (int i = 0; i < caps.size(); i++) {
    dfs(caps[i]);
  }
  bool corr = true;
  i = 0;
  while (i + 1 < n) {
    int j = 0, k = 0;
    while (j < v[i].size() && k < v[i + 1].size()) {
      if (v[i][j] != v[i + 1][k]) break;
      j++;
      k++;
    }
    if (j != v[i].size()) {
      int elem = v[i][j], elem2 = v[i + 1][k];
      if (elem < elem2) {
        if (cap[elem2] && (!cap[elem])) corr = false;
      } else {
        if (cap[elem] && (!cap[elem2])) {
          i++;
          continue;
        }
        corr = false;
      }
    }
    i++;
  }
  if (!corr)
    cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    int cnt = 0;
    vector<int> ans;
    for (int i = 1; i <= m; i++)
      if (cap[i]) ans.push_back(i);
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
