#include <bits/stdc++.h>
using namespace std;
const int MX = 100500;
vector<int> a[MX];
bool should_cap[MX];
bool should_not_cap[MX];
vector<int> dependence[MX];
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int cnt;
    cin >> cnt;
    while (cnt--) {
      int x;
      cin >> x;
      a[i].push_back(x);
    }
  }
  for (int i = 1; i < n; i++) {
    int j = 0;
    int min_sz = min(a[i].size(), a[i - 1].size());
    while (j < min_sz && a[i][j] == a[i - 1][j]) {
      j++;
    }
    if (j == min_sz) {
      if (a[i].size() < a[i - 1].size()) {
        cout << "No\n";
        return 0;
      }
      continue;
    }
    if (a[i][j] < a[i - 1][j]) {
      should_cap[a[i - 1][j]] = true;
      should_not_cap[a[i][j]] = true;
    } else {
      dependence[a[i][j]].push_back(a[i - 1][j]);
    }
  }
  vector<int> sp;
  for (int i = 0; i < MX; i++) {
    if (should_cap[i]) {
      sp.push_back(i);
    }
  }
  while (!sp.empty()) {
    int u = sp.back();
    sp.pop_back();
    for (int i = 0; i < dependence[u].size(); i++) {
      int v = dependence[u][i];
      if (!should_cap[v]) {
        should_cap[v] = true;
        sp.push_back(v);
      }
    }
  }
  for (int i = 0; i < MX; i++) {
    if (should_cap[i] && should_not_cap[i]) {
      cout << "No" << endl;
      return 0;
    }
    if (should_cap[i]) sp.push_back(i);
  }
  cout << "Yes\n";
  cout << sp.size() << "\n";
  for (int i = 0; i < sp.size(); i++) {
    cout << sp[i] << ' ';
  }
  cout << endl;
  return 0;
}
