#include <bits/stdc++.h>
using namespace std;
const int mx = 100100;
int s[2][mx], k[2], in[mx], fl[mx], vis[mx], ans[mx];
vector<int> graph[mx];
int main() {
  int n, m, cont = 0;
  bool ok = true;
  memset(in, 0, sizeof(in));
  memset(fl, 0, sizeof(fl));
  memset(vis, 0, sizeof(vis));
  scanf("%d%d", &n, &m);
  scanf("%d", &k[0]);
  for (int i = 0; i < k[0]; i++) scanf("%d", &s[0][i]);
  for (int i = 1; i < n; i++) {
    scanf("%d", &k[i % 2]);
    for (int j = 0; j < k[i % 2]; j++) scanf("%d", &s[i % 2][j]);
    bool found = false;
    for (int j = 0; j < k[i % 2] && j < k[(i - 1) % 2]; j++) {
      if (s[i % 2][j] != s[(i - 1) % 2][j]) {
        found = true;
        graph[s[i % 2][j]].push_back(s[(i - 1) % 2][j]);
        in[s[(i - 1) % 2][j]]++;
        break;
      }
    }
    if (!found && k[(i - 1) % 2] > k[i % 2]) ok = false;
  }
  queue<int> q;
  for (int i = 1; i <= m; i++)
    if (in[i] == 0) q.push(i);
  while (!q.empty()) {
    int now = q.front();
    in[now] = -1;
    q.pop();
    for (int i = 0; i < graph[now].size(); i++) {
      int nxt = graph[now][i];
      in[nxt]--;
      if (in[nxt] == 0) q.push(nxt);
      if (fl[now] == 1) {
        if (now < nxt) ok = false;
        if (!fl[nxt]) {
          fl[nxt] = 1;
          ans[cont++] = nxt;
        }
      } else if (!fl[nxt] && now < nxt) {
        fl[nxt] = 1;
        ans[cont++] = nxt;
      }
    }
  }
  for (int i = 1; i <= m; i++)
    if (in[i] > 0) ok = false;
  if (!ok)
    puts("No");
  else {
    puts("Yes");
    sort(ans, ans + cont);
    printf("%d\n", cont);
    for (int i = 0; i < cont; i++) {
      printf("%d", ans[i]);
      if (i == cont - 1)
        puts("");
      else
        printf(" ");
    }
  }
  return 0;
}
