#include <bits/stdc++.h>
using namespace std;
long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const long long maxn = 1e5 + 5;
long long n, m, x, y, z;
vector<long long> s[maxn], to[maxn];
long long vis[maxn], in[maxn];
long long get(long long x) {
  if (vis[x])
    return x - 2 * m;
  else
    return x;
}
long long diff(vector<long long> &a, vector<long long> &b) {
  long long l1 = a.size(), l2 = b.size();
  for (register long long i = 0; i <= min(l1, l2) - 1; ++i)
    if (a[i] != b[i]) return i;
  return -1;
}
void bfs() {
  queue<long long> q;
  for (register long long i = 1; i <= m; ++i)
    if (!in[i]) q.push(i);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (auto v : to[u]) {
      if (get(v) > get(u)) {
        if (vis[v]) {
          puts("No");
          exit(0);
        }
        vis[v] = 1;
      }
      in[v]--;
      if (in[v] == 0) q.push(v);
    }
  }
}
int main() {
  n = read();
  m = read();
  for (register long long i = 1; i <= n; ++i) {
    x = read();
    for (register long long j = 1; j <= x; ++j) s[i].push_back(read());
  }
  for (register long long i = 2; i <= n; ++i) {
    long long pos = diff(s[i - 1], s[i]);
    if (pos == -1) {
      if (s[i - 1].size() > s[i].size()) return puts("No") & 0;
      continue;
    }
    to[s[i][pos]].push_back(s[i - 1][pos]);
    in[s[i - 1][pos]]++;
  }
  for (register long long i = 1; i <= n; ++i) sort(to[i].begin(), to[i].end());
  bfs();
  for (register long long i = 2; i <= n; ++i) {
    long long pos = diff(s[i - 1], s[i]);
    if (pos == -1) continue;
    if (get(s[i - 1][pos]) > get(s[i][pos])) return puts("No") & 0;
  }
  puts("Yes");
  long long tmp = 0;
  for (register long long i = 1; i <= m; ++i)
    if (vis[i]) tmp++;
  cout << tmp << endl;
  for (register long long i = 1; i <= m; ++i)
    if (vis[i]) cout << i << ' ';
  return 0;
}
