#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, cmp[100005];
bool swapped[100005], swappable[100005];
vector<int> deps[100005], words[100005], bad;
set<int> nums;
set<int>::iterator it;
int mk_deps(int u) {
  swapped[u] = true;
  for (int v = 0; v < deps[u].size(); v++) {
    if (!swappable[deps[u][v]]) return -1;
    if (!swapped[deps[u][v]] && mk_deps(deps[u][v]) == -1) return -1;
  }
  return 1;
}
int get_cmp(int h, int i, int j) {
  if (j >= words[h].size() && j >= words[i].size()) {
    return 1;
  } else if (j >= words[h].size()) {
    return 1;
  } else if (j >= words[i].size()) {
    return -1;
  }
  int a = words[h][j], b = words[i][j];
  if (a == b) return 0;
  if (swapped[a] && swapped[b]) {
    return (a < b) ? 1 : -1;
  } else if (swapped[a]) {
    if (a > b) swappable[b] = false;
    return 1;
  } else if (swapped[b]) {
    if (a < b) {
      if (!swappable[a]) return -1;
      swapped[a] = true;
      return mk_deps(a);
    } else {
      return -1;
    }
  } else {
    if (a < b) {
      deps[a].push_back(b);
      deps[b].push_back(a);
      return 1;
    } else {
      if (!swappable[a]) return -1;
      swapped[a] = true, swappable[b] = false;
      return mk_deps(a);
    }
  }
}
int main() {
  memset(cmp, 0, sizeof(cmp));
  memset(swapped, false, sizeof(swapped));
  memset(swappable, true, sizeof(swappable));
  iostream::sync_with_stdio(false);
  cin.tie(NULL);
  cnt = 0;
  cin >> n >> m;
  for (int i = 0, sz, v; i < n; i++) {
    cin >> sz;
    for (int j = 0; j < sz; j++) {
      cin >> v;
      words[i].push_back(v);
    }
    if (i > 0) nums.insert(i);
  }
  bool valid = true;
  for (int h, i, j = 0; nums.size() > 0 && valid; j++) {
    bad.clear();
    for (it = nums.begin(); it != nums.end() && valid; ++it) {
      if (it == nums.begin()) {
        h = 0, i = *it;
      } else {
        h = *(--it), i = *(++it);
      }
      if (cmp[i] == 0) {
        cmp[i] = get_cmp(h, i, j);
        valid = (cmp[i] != -1);
      }
      if (words[i].size() <= j) bad.push_back(i);
    }
    for (int i = 0; i < bad.size(); i++) nums.erase(bad[i]);
  }
  if (!valid) {
    cout << "No" << '\n';
  } else {
    cout << "Yes" << '\n';
    for (int i = 1; i <= m; i++) cnt += swapped[i];
    cout << cnt << '\n';
    for (int i = 1; i <= m; i++) {
      if (swapped[i]) cout << i << " \n"[i == m];
    }
  }
}
