#include <bits/stdc++.h>
using namespace std;
vector<int> a;
bool used[100000];
vector<vector<int> > sp, g;
void dfs(int v) {
  used[v] = true;
  a.push_back(v);
  for (int i = 0; i < g[v].size(); i++)
    if (!used[g[v][i]]) dfs(g[v][i]);
}
int f(int x, int y) {
  if (used[x] && !used[y]) return 1;
  if (!used[x] && used[y]) return 2;
  if (x < y) return 1;
  if (x > y) return 2;
  if (x == y) return 0;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  sp.resize(n);
  g.resize(m + 1);
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      sp[i].push_back(x - 1);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int t = 0, j = 0;
    for (; j < min(sp[i].size(), sp[i + 1].size()); j++)
      if (sp[i][j] != sp[i + 1][j]) {
        if (sp[i][j] < sp[i + 1][j])
          t = 1;
        else
          t = 2;
        break;
      }
    if (t == 1) g[sp[i + 1][j]].push_back(sp[i][j]);
    if (t == 2) a.push_back(sp[i][j]);
  }
  for (int i = 0; i < a.size(); i++)
    if (!used[a[i]]) dfs(a[i]);
  for (int i = 0; i < n - 1; i++) {
    int t = 0;
    for (int j = 0; j < min(sp[i].size(), sp[i + 1].size()); j++) {
      int x = f(sp[i][j], sp[i + 1][j]);
      if (x) {
        t = x;
        break;
      }
    }
    if (t == 2 || (t == 0 && sp[i + 1].size() < sp[i].size())) {
      printf("No");
      return 0;
    }
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  printf("Yes\n%d\n", a.size());
  for (int i = 0; i < a.size(); i++) printf("%d ", a[i] + 1);
  return 0;
}
