#include <bits/stdc++.h>
using namespace std;
vector<long long int> words[100005], deps[100005];
int noall[100005], iscap[100005];
set<long long int> caps;
int capitalize(int l) {
  if (noall[l] == 1) return 0;
  if (iscap[l] == 1) return 1;
  int ret = 0;
  for (int i = 0; i < int(deps[l].size()); i++)
    ret = max(capitalize(deps[l][i]), ret);
  if (deps[l].size() == 0) ret = 1;
  caps.insert(l);
  iscap[l] = 1;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, ansflag = 1;
  cin >> n >> m;
  for (int i = 0; i < int(n); i++) {
    int l;
    cin >> l;
    for (int j = 0; j < int(l); j++) {
      int letter;
      cin >> letter;
      words[i].push_back(letter);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int j = 0;
    while (words[i][j] == words[i + 1][j] &&
           j < min(words[i].size(), words[i + 1].size()))
      j++;
    if (j == words[i].size())
      continue;
    else if (j == words[i + 1].size()) {
      ansflag = 0;
      break;
    } else {
      if (iscap[words[i][j]] == 1) {
        if (words[i][j] <= words[i + 1][j])
          continue;
        else if (iscap[words[i + 1][j]] == 0)
          noall[words[i + 1][j]] = 1;
        else {
          ansflag = 0;
          break;
        }
      } else if (iscap[words[i][j]] == 0) {
        if (words[i][j] <= words[i + 1][j]) {
          if (iscap[words[i + 1][j]] == 0)
            deps[words[i + 1][j]].push_back(words[i][j]);
          else if (iscap[words[i + 1][j]] == 1) {
            if (capitalize(words[i][j]) == 0) {
              ansflag = 0;
              break;
            }
          }
        } else {
          if (iscap[words[i + 1][j]] == 0) {
            noall[words[i + 1][j]] = 1;
            if (capitalize(words[i][j]) == 0) {
              ansflag = 0;
              break;
            }
          } else {
            ansflag = 0;
            break;
          }
        }
      }
    }
  }
  if (ansflag == 0)
    cout << "No" << '\n';
  else {
    cout << "Yes" << '\n' << caps.size() << '\n';
    for (auto it = caps.begin(); it != caps.end(); it++) cout << *it << " ";
  }
  return 0;
}
