#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const double PI = acos(-1.0);
const long long N = 1e5 + 100;
bool fl[N];
long long n, m;
vector<vector<long long>> ar;
long long get(long long i, long long j) {
  if (ar[i].size() <= j) {
    return 0;
  }
  if (fl[ar[i][j] / 1000000]) {
    return ar[i][j] / 1000000;
  }
  return ar[i][j];
}
vector<long long> ans;
long long hi_wo = 0;
void solve(long long start, long long end, long long j) {
  if (start == end) {
    return;
  }
  long long f = 0;
  for (long long i = start; i <= end; i++) {
    if (ar[i].size() > j) {
      f = 1;
      break;
    }
  }
  if (!f) {
    return;
  }
  long long flag = 0;
  for (long long i = end; i > start; i--) {
    if (flag) {
      if (get(i, j) > 100000) {
        ans.push_back(get(i, j) / 1000000);
        fl[get(i, j) / 1000000] = 1;
      }
      continue;
    }
    if (get(i, j) < get(i - 1, j)) {
      flag = 1;
    }
  }
  if (flag) {
    if (get(start, j) > 100000) {
      ans.push_back(get(start, j) / 1000000);
      fl[get(start, j) / 1000000] = 1;
    }
  }
  for (long long i = start; i < end; i++) {
    if (get(i, j) > get(i + 1, j)) {
      cout << "No\n";
      exit(0);
    }
  }
  for (long long i = start; i <= end; i++) {
    long long x = i;
    while (x <= end && get(x, j) == get(i, j)) {
      x++;
    }
    solve(i, x - 1, j + 1);
    i = x - 1;
  }
}
void check(long long start, long long end, long long j) {
  if (start == end) {
    return;
  }
  long long f = 0;
  for (long long i = start; i <= end; i++) {
    if (ar[i].size() > j) {
      f = 1;
      break;
    }
  }
  if (!f) {
    return;
  }
  for (long long i = start; i < end; i++) {
    if (get(i, j) > get(i + 1, j)) {
      cout << "No\n";
      exit(0);
    }
  }
  for (long long i = start; i <= end; i++) {
    long long x = i;
    while (x <= end && get(x, j) == get(i, j)) {
      x++;
    }
    check(i, x - 1, j + 1);
    i = x - 1;
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  ar.resize(n);
  for (long long i = 0; i < n; i++) {
    long long l;
    cin >> l;
    hi_wo = max(hi_wo, l);
    for (long long j = 0; j < l; j++) {
      long long x;
      cin >> x;
      ar[i].push_back(x * 1000000);
    }
  }
  solve(0, n - 1, 0);
  check(0, n - 1, 0);
  set<long long> se;
  for (long long i = 0; i < ans.size(); i++) {
    if (ans[i] > 0) {
      se.insert(ans[i]);
    }
  }
  cout << "Yes\n";
  cout << se.size() << "\n";
  for (auto x : se) {
    cout << x << " ";
  }
}
