#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int marked[N];
vector<int> in[N], out[N];
vector<int> s[N];
void dfs(int u) {
  marked[u] = 1;
  for (auto v : out[u]) {
    if (!marked[v]) {
      dfs(v);
    }
  }
}
int val[N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int l;
    scanf("%d", &l);
    s[i].resize(l);
    for (int j = 0; j < l; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 2; i <= n; i++) {
    int p = 0;
    while (p < s[i - 1].size() && p < s[i].size()) {
      if (s[i - 1][p] < s[i][p]) {
        in[s[i][p]].push_back(s[i - 1][p]);
        out[s[i - 1][p]].push_back(s[i][p]);
        break;
      } else if (s[i - 1][p] > s[i][p]) {
        marked[s[i - 1][p]] = 2;
        marked[s[i][p]] = 1;
        break;
      }
      p++;
    }
    if (p == s[i].size() && s[i - 1].size() > s[i].size()) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (marked[i] == 1) {
      dfs(i);
    }
  }
  int k = 0;
  for (int i = 1; i <= m; i++) {
    if (!marked[i]) marked[i] = 2;
    if (marked[i] == 1)
      val[i] = m + i;
    else
      val[i] = i, k++;
  }
  for (int i = 2; i <= n; i++) {
    int p = 0;
    while (p < s[i - 1].size() && p < s[i].size()) {
      int a = s[i - 1][p], b = s[i][p];
      a = val[a], b = val[b];
      if (a > b) {
        cout << "No" << endl;
        return 0;
      } else if (a < b)
        break;
      p++;
    }
  }
  cout << "Yes" << endl;
  cout << k << endl;
  for (int i = 1; i <= m; i++) {
    if (marked[i] == 2) {
      printf("%d ", i);
    }
  }
  cout << endl;
}
