#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, m;
vector<int> G[maxn];
int col[maxn];
int a[2][maxn];
int ls[maxn];
int in[maxn];
int len[maxn];
vector<int> ans;
bool dfs(int u, int c) {
  if (col[u] && col[u] != c) return 1;
  if (col[u] == c) return 0;
  col[u] = c;
  for (int i = 0; i < len[u]; i++) {
    int v = G[u][i];
    if (!dfs(v, c)) return 0;
  }
  return 1;
}
bool toposort() {
  memset(ls, 0, sizeof(ls));
  queue<int> q;
  for (int i = 1; i <= m; i++) {
    if (in[i] == 0) {
      q.push(i);
      ls[i] = 2;
    }
  }
  if (q.empty()) return 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < len[u]; i++) {
      int v = G[u][i];
      if (u > v) {
        if (ls[u] == 1)
          ls[v] = 1;
        else if (!ls[v])
          ls[v] = 2;
      } else {
        if (ls[u] == 1)
          return 0;
        else
          ls[v] = 1;
      }
      in[v]--;
      if (!in[v]) {
        q.push(v);
      }
    }
  }
  for (int i = 1; i <= m; i++)
    if (in[i]) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  int l, ll;
  cin >> l;
  for (int i = 1; i <= l; i++) cin >> a[1][i];
  ll = l;
  bool suc = 1;
  for (int i = 2; i <= n; i++) {
    int t = i & 1;
    cin >> l;
    for (int j = 1; j <= l; j++) cin >> a[t][j];
    for (int j = 1; j <= min(l, ll); j++) {
      if (a[t][j] == a[t ^ 1][j]) {
        if (j == l && l < ll) {
          suc = 0;
          break;
        }
        continue;
      }
      G[a[t][j]].push_back(a[t ^ 1][j]);
      break;
    }
    ll = l;
  }
  memset(in, 0, sizeof(in));
  for (int i = 1; i <= m; i++) {
    sort(G[i].begin(), G[i].end());
    len[i] = unique(G[i].begin(), G[i].end()) - G[i].begin();
    for (int j = 0; j < len[i]; j++) in[G[i][j]]++;
  }
  if (suc && toposort()) {
    cout << "Yes" << endl;
    for (int i = 1; i <= m; i++)
      if (ls[i] == 1) ans.push_back(i);
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      if (i > 0) cout << ' ';
      cout << ans[i];
    }
    if (ans.size()) cout << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
