#include <bits/stdc++.h>
using namespace std;
int n, m, a[3000010], b[3000010], as, bs, du[3000010], q[3000010], qs;
bool ha[3000010];
bool pan;
vector<int> e[3000010];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d", &bs);
  for (int i = 1; i <= bs; i++) scanf("%d", &b[i]);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &as);
    for (int j = 1; j <= as; j++) scanf("%d", &a[j]);
    int w = 0;
    for (int j = 1; j <= min(as, bs); j++)
      if (a[j] != b[j]) {
        w = j;
        break;
      }
    if (w == 0) {
      if (as < bs) {
        pan = 1;
        break;
      }
    } else {
      e[a[w]].push_back(b[w]);
      du[b[w]]++;
    }
    bs = as;
    for (int j = 1; j <= as; j++) b[j] = a[j];
  }
  for (int i = 1; i <= m; i++)
    if (du[i] == 0) q[++qs] = i;
  int ql = 1;
  while (ql <= qs) {
    int k = q[ql];
    if (ha[k]) {
      for (int now = 0; now < (int)e[k].size(); now++) {
        int kk = e[k][now];
        du[kk]--;
        if (du[kk] == 0) q[++qs] = kk;
        if (kk > k) {
          pan = 1;
        } else
          ha[kk] = 1;
      }
    } else {
      for (int now = 0; now < (int)e[k].size(); now++) {
        int kk = e[k][now];
        du[kk]--;
        if (du[kk] == 0) q[++qs] = kk;
        if (kk > k) {
          ha[kk] = 1;
        }
      }
    }
    ql++;
  }
  for (int i = 1; i <= m; i++)
    if (du[i] > 0) pan = 1;
  if (pan)
    printf("No\n");
  else {
    printf("Yes\n");
    int sum = 0, sum2 = 0;
    for (int i = 1; i <= m; i++)
      if (ha[i]) sum++;
    printf("%d\n", sum);
    for (int i = 1; i <= m; i++)
      if (ha[i]) {
        sum2++;
        printf("%d%c", i, (sum == sum2) ? '\n' : ' ');
      }
  }
  return 0;
}
