#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int INF = 1e6;
int n, m, val[N];
vector<int> g[N], a[N];
set<int> cap;
bool flag, vis[N];
void check(int idx) {
  if (a[idx - 1] > a[idx]) {
    for (int i = 0; i < min(a[idx - 1].size(), a[idx].size()); i++)
      if (a[idx - 1][i] > a[idx][i]) {
        if (val[a[idx - 1][i]] > 0) {
          val[a[idx - 1][i]] -= INF;
          cap.insert(a[idx - 1][i]);
        }
        return;
      }
    flag = 1;
  } else if (a[idx - 1] < a[idx]) {
    for (int i = 0; i < min(a[idx - 1].size(), a[idx].size()); i++) {
      if (a[idx][i] > a[idx - 1][i]) {
        g[a[idx][i]].push_back(a[idx - 1][i]);
        return;
      }
    }
  }
}
void dfs(int v) {
  vis[v] = 1;
  if (val[v] > 0) {
    val[v] -= INF;
    cap.insert(v);
  }
  for (auto u : g[v])
    if (!vis[u]) dfs(u);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    int t1;
    scanf("%d", &t1);
    a[i].resize(t1);
    for (int j = 0; j < t1; j++) scanf("%d", &a[i][j]);
  }
  for (int i = 1; i <= m; i++) val[i] = i;
  for (int i = 1; i < n; i++) check(i);
  if (flag) return puts("No"), 0;
  for (auto u : cap)
    if (!vis[u]) dfs(u);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < a[i].size(); j++) a[i][j] = val[a[i][j]];
  for (int i = 1; i < n; i++)
    if (a[i] < a[i - 1]) flag = 1;
  if (flag) return puts("No"), 0;
  puts("Yes");
  printf("%d\n", (int)cap.size());
  for (auto u : cap) printf("%d ", u);
  puts("");
  return 0;
}
