#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
vector<int> a[maxn], edge[maxn];
int n, m, x, k[maxn], dif[maxn], turn[maxn], ans[maxn];
bool vis[maxn];
void pre() {
  memset(dif, 0, sizeof(dif));
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < min(k[i], k[i + 1]); j++) {
      if (a[i][j] == a[i + 1][j])
        dif[i]++;
      else
        break;
    }
  }
  return;
}
void solve() {
  memset(turn, 0, sizeof(turn));
  for (int i = 0; i < n - 1; i++) {
    if (dif[i] == k[i] && k[i] <= k[i + 1]) continue;
    if (dif[i] == k[i + 1] && k[i] > k[i + 1]) {
      printf("No\n");
      return;
    }
    int j = dif[i];
    if (a[i][j] > a[i + 1][j]) {
      if (turn[a[i][j]] != 2)
        turn[a[i][j]] = 1;
      else {
        printf("No\n");
        return;
      }
      if (turn[a[i + 1][j]] != 1)
        turn[a[i + 1][j]] = 2;
      else {
        printf("No\n");
        return;
      }
    }
    if (a[i][j] < a[i + 1][j]) {
      edge[a[i + 1][j]].push_back(a[i][j]);
    }
  }
  queue<int> q;
  for (int i = 1; i <= 1e5; i++)
    if (!vis[i] && turn[i] == 1) {
      q.push(i);
      vis[i] = 1;
      while (!q.empty()) {
        int x = q.front();
        for (int j = 0; j < edge[x].size(); j++) {
          int node = edge[x][j];
          if (!vis[node]) {
            if (turn[node] == 2) {
              printf("No\n");
              return;
            }
            q.push(node);
            vis[node] = 1;
          }
        }
        q.pop();
      }
    }
  int cnt = 0;
  for (int i = 1; i <= 1e5; i++)
    if (vis[i]) ans[cnt++] = i;
  printf("Yes\n");
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) printf("%d ", ans[i]);
  return;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &k[i]);
    for (int j = 0; j < k[i]; j++) {
      scanf("%d", &x);
      a[i].push_back(x);
    }
  }
  pre();
  solve();
  return 0;
}
