#include <bits/stdc++.h>
using namespace std;
const double PI =
    3.141592653589793238462643383279502884197169399375105820974944;
long long n, m;
vector<long long> a[100005];
vector<long long> adj[100005];
bitset<100005> cap;
bitset<100005> ncap;
bitset<100005> vis;
void dfs(long long s) {
  vis[s] = 1;
  for (auto x : adj[s]) {
    if (vis[x]) continue;
    cap[x] = 1;
    dfs(x);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < (n); i++) {
    long long l;
    cin >> l;
    for (long long j = 0; j < (l); j++) {
      long long x;
      cin >> x;
      a[i].push_back(x);
    }
  }
  for (long long i = (1); i < (n); i++) {
    long long j = 0;
    long long ln = min(a[i].size(), a[i - 1].size());
    while (j < ln and a[i - 1][j] == a[i][j]) j++;
    if (j == ln) {
      if (a[i - 1].size() > a[i].size()) {
        cout << "No\n";
        return 0;
      }
    } else if (a[i - 1][j] < a[i][j]) {
      adj[a[i][j]].push_back(a[i - 1][j]);
    } else {
      cap[a[i - 1][j]] = 1;
      ncap[a[i][j]] = 1;
    }
  }
  for (long long i = (1); i < (m + 1); i++) {
    if (cap[i]) {
      if (!vis[i]) dfs(i);
    }
  }
  vector<long long> ans;
  for (long long i = (1); i < (m + 1); i++) {
    if (cap[i] and ncap[i]) {
      cout << "No\n";
      return 0;
    } else if (cap[i])
      ans.push_back(i);
  }
  cout << "Yes\n";
  cout << ans.size() << endl;
  for (auto x : ans) cout << x << " ";
}
