#include <bits/stdc++.h>
using namespace std;
char getc() {
  char c = getchar();
  while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9'))
    c = getchar();
  return c;
}
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
int n, m, len, p[100010];
bool flag[100010], same[100010];
vector<int> a[100010], pre[100010];
bool astb(int i, int j, int x) {
  if (a[i].size() <= x) return 1;
  if (a[j].size() <= x) return 0;
  if (flag[a[j][x]] != flag[a[i][x]])
    return flag[a[i][x]];
  else
    return a[i][x] <= a[j][x];
}
void error() {
  cout << "No";
  exit(0);
}
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    int m = read();
    len = max(len, m);
    for (int j = 0; j < m; j++)
      pre[i].push_back(p[j]), p[j] = i, a[i].push_back(read());
  }
  for (int t = 3; t; t--) {
    for (int i = 1; i < n; i++) same[i] = 1;
    for (int i = 0; i < len; i++) {
      for (int k = p[i]; k >= 1; k = pre[k][i])
        if (k < n) {
          if (same[k] && !astb(k, k + 1, i)) {
            flag[a[k][i]] = 1;
            if (!astb(k, k + 1, i)) error();
          }
          same[k] &= astb(k, k + 1, i) && astb(k + 1, k, i);
        }
    }
  }
  for (int i = 1; i < n; i++) {
    int f = -1;
    for (int j = 0; j < min(a[i].size(), a[i + 1].size()); j++) {
      if (a[i][j] != a[i + 1][j]) {
        if (flag[a[i][j]] == flag[a[i + 1][j]])
          f = a[i][j] < a[i + 1][j];
        else
          f = flag[a[i][j]];
        break;
      }
    }
    if (f == 0) error();
    if (f == -1)
      if (a[i].size() > a[i + 1].size()) error();
  }
  cout << "Yes" << endl;
  int cnt = 0;
  for (int i = 1; i <= m; i++)
    if (flag[i]) cnt++;
  cout << cnt << endl;
  for (int i = 1; i <= m; i++)
    if (flag[i]) cout << i << ' ';
  return 0;
}
