#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
set<long long int> cap;
vector<long long int> v[N];
void dfs(long long int s) {
  cap.insert(s);
  for (auto u : v[s]) dfs(u);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m;
  cin >> n >> m;
  vector<long long int> s[n], ac;
  for (long long int i = (long long int)0; i <= (long long int)n - 1; i++) {
    long long int sz;
    cin >> sz;
    for (long long int j = (long long int)0; j <= (long long int)sz - 1; j++) {
      long long int x;
      cin >> x;
      s[i].push_back(x);
    }
  }
  for (long long int i = (long long int)0; i <= (long long int)n - 2; i++) {
    vector<long long int> a = s[i], b = s[i + 1];
    long long int sz = min(a.size(), b.size());
    long long int in = 0;
    while (in < sz && a[in] == b[in]) in++;
    if (in == sz && a.size() > b.size()) {
      cout << "No"
           << "\n";
      return 0;
    }
    if (in == sz) continue;
    if (a[in] < b[in])
      v[b[in]].push_back(a[in]);
    else
      ac.push_back(a[in]);
  }
  for (auto x : ac) dfs(x);
  for (long long int i = (long long int)0; i <= (long long int)n - 2; i++) {
    vector<long long int> a = s[i], b = s[i + 1];
    long long int sz = min(a.size(), b.size());
    long long int in = 0;
    while (in < sz && a[in] == b[in]) in++;
    if (in == sz) continue;
    if (cap.find(a[in]) == cap.end() && cap.find(b[in]) != cap.end()) {
      cout << "No"
           << "\n";
      return 0;
    } else if (cap.find(a[in]) != cap.end() && cap.find(b[in]) == cap.end())
      continue;
    else {
      if (a[in] > b[in]) {
        cout << "No"
             << "\n";
        return 0;
      }
    }
  }
  cout << "Yes"
       << "\n";
  cout << cap.size() << "\n";
  for (auto x : cap) cout << x << " ";
  cout << "\n";
}
