#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1000 * 1000 * 1000;
const long long LINF = (long long)INF * INF;
int n, m;
vector<int> s[100100];
int mark[100100];
vector<int> adj[100100];
vector<int> badj[100100];
void cmpr(const vector<int> &s, const vector<int> &t) {
  int i = 0;
  while (i < (int)min(s.size(), t.size()) && s[i] == t[i]) i++;
  if (i == (int)t.size() && i < (int)s.size()) {
    ;
    ;
    cout << "No\n";
    exit(0);
  }
  if (i < (int)s.size() && i < (int)t.size()) {
    if (s[i] > t[i]) {
      if (mark[s[i]] == 2 || mark[t[i]] == 1) {
        ;
        ;
        cout << "No\n";
        exit(0);
      }
      mark[s[i]] = 1;
      mark[t[i]] = 2;
    } else {
      adj[t[i]].push_back(s[i]);
      badj[s[i]].push_back(t[i]);
    }
  }
}
bool seen[100100];
void dfs(int v, vector<int> *adj, int state) {
  seen[v] = true;
  mark[v] = state;
  for (int u : adj[v]) {
    if (mark[u] && mark[u] != state) {
      ;
      ;
      cout << "No\n";
      exit(0);
    }
    if (seen[u]) continue;
    dfs(u, adj, state);
  }
}
int32_t main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = (0); i < (n); i++) {
    int len;
    cin >> len;
    for (int j = (0); j < (len); j++) {
      int x;
      cin >> x;
      s[i].push_back(x);
    }
  }
  for (int i = (0); i < (n - 1); i++) {
    cmpr(s[i], s[i + 1]);
  }
  for (int i = (1); i < (m + 1); i++) {
    if (seen[i]) continue;
    if (mark[i] == 1) {
      dfs(i, adj, 1);
    } else if (mark[i] == 2) {
      dfs(i, badj, 2);
    }
  }
  cout << "Yes\n";
  vector<int> ans;
  for (int i = (1); i < (m + 1); i++) {
    if (mark[i] == 1) ans.push_back(i);
  }
  cout << ans.size() << '\n';
  for (int u : ans) cout << u << ' ';
  cout << '\n';
  return 0;
}
