#include <bits/stdc++.h>
using namespace std;
vector<int> w[100001], adj[100001];
int v[100001], f[100001];
void dfs(int cur) {
  v[cur] = 1;
  for (auto& next : adj[cur]) {
    dfs(next);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int l, s;
    cin >> l;
    for (; l; l--) cin >> s, w[i].push_back(s - 1);
  }
  memset(v, 0, sizeof(v));
  memset(f, 0, sizeof(f));
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < w[i - 1].size(); j++) {
      if (j >= w[i].size()) {
        cout << "No\n";
        return 0;
      }
      if (w[i - 1][j] != w[i][j]) {
        if (w[i - 1][j] > w[i][j]) {
          f[w[i][j]] = 1;
        } else {
          adj[w[i][j]].push_back(w[i - 1][j]);
        }
        break;
      }
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < w[i - 1].size(); j++) {
      if (w[i - 1][j] != w[i][j]) {
        if (w[i - 1][j] > w[i][j]) {
          dfs(w[i - 1][j]);
        }
        break;
      }
    }
  }
  int k = 0;
  for (int i = 0; i < m; i++) {
    if (v[i] && f[i]) {
      cout << "No\n";
      return 0;
    }
    if (v[i]) k++;
  }
  cout << "Yes\n" << k << endl;
  for (int i = 0; i < m; i++) {
    if (v[i]) cout << i + 1 << " ";
  }
  cout << endl;
}
