#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
int n, m, len[N], forb[N][2], it[N], was[N];
vector<int> s[N], g[N][2];
set<int> ans;
void no() {
  puts("No");
  exit(0);
}
void compare(int ind) {
  vector<int> a = s[ind], b = s[ind + 1];
  int n1 = len[ind], m1 = len[ind + 1], j = 0;
  for (; j < min(n1, m1) && a[j] == b[j]; ++j)
    ;
  it[ind] = j;
  if (j == min(n1, m1)) {
    if (n1 > m1) no();
    return;
  }
  if (a[j] > b[j]) {
    forb[a[j]][0] = 1;
    forb[b[j]][1] = 1;
  } else {
    g[a[j]][0].push_back(b[j]);
    g[b[j]][1].push_back(a[j]);
  }
}
void dfs(int v) {
  if (forb[v][1]) no();
  if (was[v]) return;
  was[v] = 1;
  ans.insert(v);
  for (int u : g[v][1]) {
    dfs(u);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &len[i]);
    s[i].resize(len[i]);
    for (int j = 0; j < len[i]; ++j) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 0; i < n - 1; ++i) {
    compare(i);
  }
  for (int i = 1; i < m + 1; ++i) {
    if (forb[i][0] && forb[i][1]) no();
  }
  for (int i = 1; i < m + 1; ++i) {
    if (forb[i][0]) dfs(i);
  }
  puts("Yes");
  printf("%d\n", ans.size());
  for (int i : ans) printf("%d ", i);
  return 0;
}
