#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int l[maxn];
vector<int> v[maxn];
vector<int> adj[maxn];
vector<int> ans;
bool mark[maxn], mr[maxn];
void dfs(int v) {
  mr[v] = true;
  ans.push_back(v);
  for (int u : adj[v]) {
    if (!mr[u]) dfs(u);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> l[i];
    for (int j = 0; j < l[i]; j++) {
      int x;
      cin >> x;
      v[i].push_back(x);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int k = 0;
    while (k < l[i] && k < l[i + 1] && v[i][k] == v[i + 1][k]) {
      k++;
    }
    if (k == l[i]) {
      continue;
    }
    if (k == l[i + 1]) {
      cout << "No";
      return 0;
    }
    if (v[i][k] < v[i + 1][k]) {
      adj[v[i + 1][k]].push_back(v[i][k]);
    } else {
      mark[v[i][k]] = true;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (mark[i] && !mr[i]) {
      dfs(i);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int k = 0;
    while (k < l[i] && k < l[i + 1] && v[i][k] == v[i + 1][k]) {
      k++;
    }
    if (k == l[i]) {
      continue;
    }
    if ((mr[v[i + 1][k]] && !mr[v[i + 1][k]]) ||
        (v[i][k] > v[i + 1][k] && mr[v[i + 1][k]])) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes" << endl;
  cout << ans.size() << endl;
  for (int u : ans) cout << u << " ";
  return 0;
}
