#include <bits/stdc++.h>
using namespace std;
vector<int> dep[100011];
vector<int> invdep[100011];
bool change[100011];
vector<int> second[100011];
int len[100011];
void go(int r) {
  if (!change[r]) return;
  for (auto x : dep[r]) {
    if (!change[x]) {
      change[x] = 1;
      go(x);
    }
  }
}
int main() {
  int n, m, x;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> len[i];
    for (int j = 0; j < len[i]; j++) {
      cin >> x;
      second[i].push_back(x);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int sz = min(len[i], len[i + 1]);
    bool notequal = 0;
    for (int j = 0; j < sz; j++) {
      if (second[i][j] != second[i + 1][j]) {
        if (second[i][j] > second[i + 1][j]) {
          change[second[i][j]] = 1;
          invdep[second[i][j]].push_back(second[i + 1][j]);
        } else {
          dep[second[i + 1][j]].push_back(second[i][j]);
        }
        notequal = 1;
        break;
      }
    }
    if (!notequal) {
      if (len[i] > len[i + 1]) {
        cout << "No";
        return 0;
      }
    }
  }
  for (int j = 1; j <= m; j++) {
    go(j);
  }
  for (int j = 1; j <= m; j++) {
    if (change[j]) {
      for (auto x : invdep[j]) {
        if (change[x]) {
          cout << "No";
          return 0;
        }
      }
    }
  }
  cout << "Yes\n";
  int cnt = 0;
  for (int j = 1; j <= m; j++) {
    if (change[j]) cnt++;
  }
  cout << cnt << "\n";
  for (int j = 1; j <= m; j++) {
    if (change[j]) {
      cout << j << " ";
    }
  }
}
