#include <bits/stdc++.h>
using namespace std;
typedef unsigned int UI;
typedef long int LI;
typedef unsigned long int ULI;
typedef long long int LL;
typedef unsigned long long int ULL;
const LL MOD = 1e9 + 7;
inline int scanInt() {
  int n = 0;
  char ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 1) + (n << 3) + (int)(ch - '0');
    ch = getchar();
  }
  return n * sign;
}
inline LL scanLong() {
  LL n = 0;
  char ch = getchar();
  LL sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 1) + (n << 3) + (LL)(ch - '0');
    ch = getchar();
  }
  return n * sign;
}
const LL MAX = 1e5 + 10;
LL N, M;
vector<LL> words[MAX];
set<LL> adj[MAX];
bool capital[MAX], visited[MAX];
bool possible = true;
void addEdges(LL b) {
  LL a = b - 1;
  LL l = min(words[a].size(), words[b].size());
  for (__typeof(l) i = (0) - ((0) > (l)); i != (l) - ((0) > (l));
       i += 1 - 2 * ((0) > (l))) {
    if (words[a][i] != words[b][i]) {
      if (words[a][i] < words[b][i])
        adj[words[b][i]].insert(words[a][i]);
      else if (words[a][i] > words[b][i])
        capital[words[a][i]] = true;
      break;
    }
    if (i + 1 == l && words[b].size() < words[a].size()) possible = false;
  }
}
void dfs(LL src) {
  capital[src] = true;
  visited[src] = true;
  for (__typeof(adj[src].end()) it = adj[src].begin(); it != adj[src].end();
       it++) {
    if (!visited[*it]) dfs(*it);
  }
}
bool compare(LL a, LL b) {
  if (a < b && (capital[a] || !capital[b])) return true;
  if (a > b && (capital[a] && !capital[b])) return true;
  if (a == b) return true;
  return false;
}
void check(LL b) {
  LL a = b - 1;
  LL l = min(words[a].size(), words[b].size());
  for (__typeof(l) i = (0) - ((0) > (l)); i != (l) - ((0) > (l));
       i += 1 - 2 * ((0) > (l))) {
    if (words[a][i] != words[b][i]) {
      if (!compare(words[a][i], words[b][i])) possible = false;
      break;
    }
  }
}
int main() {
  N = scanLong();
  M = scanLong();
  for (__typeof(N) i = (0) - ((0) > (N)); i != (N) - ((0) > (N));
       i += 1 - 2 * ((0) > (N))) {
    LL l = scanLong();
    ;
    for (__typeof(l) j = (0) - ((0) > (l)); j != (l) - ((0) > (l));
         j += 1 - 2 * ((0) > (l)))
      words[i].push_back(scanLong());
    if (i > 0) addEdges(i);
  }
  for (__typeof(M + 1) i = (1) - ((1) > (M + 1));
       i != (M + 1) - ((1) > (M + 1)); i += 1 - 2 * ((1) > (M + 1)))
    if (capital[i]) dfs(i);
  for (__typeof(N) i = (1) - ((1) > (N)); i != (N) - ((1) > (N));
       i += 1 - 2 * ((1) > (N)))
    check(i);
  if (possible) {
    puts("Yes");
    vector<LL> caps;
    for (__typeof(M + 1) i = (1) - ((1) > (M + 1));
         i != (M + 1) - ((1) > (M + 1)); i += 1 - 2 * ((1) > (M + 1)))
      if (capital[i]) caps.push_back(i);
    printf("%lld ", (LL)caps.size());
    printf("\n");
    for (__typeof(caps.end()) it =
             (caps.begin()) - ((caps.begin()) > (caps.end()));
         it != (caps.end()) - ((caps.begin()) > (caps.end()));
         it += 1 - 2 * ((caps.begin()) > (caps.end())))
      printf("%lld ", *it);
    printf("\n");
  } else
    puts("No");
}
