#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 23;
const int delta = (int)1e9 + 7;
int n, m;
vector<int> a[(int)2e5 + 23], g[(int)2e5 + 23], ans;
bool f1[(int)2e5 + 23], f2[(int)2e5 + 23];
bool color[(int)2e5 + 23];
void dfs(int u) {
  color[u] = true;
  for (int i = 0; i < g[u].size(); i++) {
    if (!color[g[u][i]]) dfs(g[u][i]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int l;
    cin >> l;
    for (int j = 1; j <= l; j++) {
      int x;
      cin >> x;
      a[i].push_back(x);
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    int loc = 0;
    while (loc < a[i].size() && loc < a[i + 1].size() &&
           a[i][loc] == a[i + 1][loc]) {
      loc++;
    }
    if (a[i].size() > a[i + 1].size() && loc == a[i + 1].size()) {
      cout << "No";
      return 0;
    }
    if (loc == a[i].size()) continue;
    if (a[i][loc] < a[i + 1][loc]) {
      g[a[i + 1][loc]].push_back(a[i][loc]);
      continue;
    }
    f1[a[i][loc]] = true;
    f2[a[i + 1][loc]] = true;
  }
  for (int i = 1; i <= m; i++) {
    if (f1[i] && !color[i]) dfs(i);
  }
  for (int i = 1; i <= m; i++) {
    if (color[i]) {
      ans.push_back(i);
      if (f2[i]) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
