#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1e5 + 5;
vector<int> ans;
vector<int> a[Nmax];
vector<int> adj[Nmax];
int n, m;
int sz[Nmax];
bool cap[Nmax];
bool ban[Nmax];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> sz[i];
    a[i].resize(sz[i]);
    for (int j = 0; j < sz[i]; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i < n; i++) {
    bool ok = false;
    for (int j = 0; j < min(sz[i], sz[i + 1]); j++) {
      if (a[i][j] != a[i + 1][j]) {
        ok = true;
        if (a[i][j] > a[i + 1][j]) {
          cap[a[i][j]] = true;
          ban[a[i + 1][j]] = true;
        } else {
          adj[a[i + 1][j]].push_back(a[i][j]);
        }
        break;
      }
    }
    if (!ok && sz[i] > sz[i + 1]) return cout << "No", 0;
  }
  for (int i = m; i >= 1; i--) {
    if (!cap[i]) continue;
    if (cap[i] && ban[i]) return cout << "No", 0;
    for (int j : adj[i]) {
      cap[j] = true;
    }
    ans.push_back(i);
  }
  cout << "Yes\n";
  cout << ans.size() << "\n";
  for (int x : ans) cout << x << " ";
  return 0;
}
