#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int MAXM = 100010;
int a[MAXM];
bool cg[MAXN];
vector<int> ve[MAXN];
int fact(int id) {
  if (cg[id]) return a[id] - 100000;
  return a[id];
}
bool ans, ok;
void dfs(int l, int r, int id) {
  if (!ans) return;
  if (l >= r) return;
  while (l <= r && id >= ve[l].size()) l++;
  for (int i = l + 1; i <= r; ++i) {
    if (id >= ve[i].size()) {
      ans = false;
      return;
    }
    if (fact(ve[i][id]) < fact(ve[i - 1][id])) {
      for (int j = i - 1; j >= l; --j) {
        if (fact(ve[j + 1][id]) > fact(ve[j][id])) {
          break;
        }
        if (!cg[ve[j][id]]) {
          ok = true;
        }
        cg[ve[j][id]] = true;
        if (fact(ve[j + 1][id]) < fact(ve[j][id])) {
          ans = false;
          return;
        }
      }
    }
  }
  int kk = l;
  for (int i = l; i <= r; ++i) {
    if (ve[i][id] != ve[kk][id]) {
      dfs(kk, i - 1, id + 1);
      if (!ans) return;
      kk = i;
    }
    if (i == r && ve[i][id] == ve[kk][id]) {
      dfs(kk, i, id + 1);
      if (!ans) return;
    }
  }
}
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  memset(cg, 0, sizeof(cg));
  for (int i = 1; i <= m; ++i) a[i] = i;
  for (int i = 1, l; i <= n; ++i) {
    scanf("%d", &l);
    for (int j = 1, ti; j <= l; j++) {
      scanf("%d", &ti);
      ve[i].push_back(ti);
    }
  }
  ans = 1;
  ok = 1;
  while (ok && ans) {
    ok = 0;
    dfs(1, n, 0);
  }
  dfs(1, n, 0);
  if (!ans) {
    puts("No");
    return 0;
  }
  int sum = 0;
  for (int i = 1; i <= m; ++i)
    if (cg[i]) ++sum;
  puts("Yes");
  printf("%d\n", sum);
  for (int i = 1; i <= m; ++i)
    if (cg[i]) printf("%d ", i);
  return 0;
}
