#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
set<int> zb;
set<int>::iterator it;
vector<int> wek[N], inEdges[N];
int n, m, i, j, x, a, b, l;
set<pair<int, int> > nsEdges;
pair<int, int> vv;
bool cont(int v) { return zb.find(v) != zb.end(); }
int main() {
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    wek[i].resize(0);
    for (j = 0; j < x; j++) {
      scanf("%d", &l);
      wek[i].push_back(l);
    }
  }
  for (i = 0; i < m; i++) inEdges[i].resize(0);
  zb.clear();
  nsEdges.clear();
  for (i = 0; i < n - 1; i++) {
    j = 0;
    while (j < wek[i].size() && j < wek[i + 1].size() &&
           wek[i][j] == wek[i + 1][j]) {
      j++;
    }
    if (j == wek[i].size() && j <= wek[i + 1].size()) {
      continue;
    }
    if (j == wek[i + 1].size()) {
      printf("No\n");
      return 0;
    }
    inEdges[wek[i + 1][j]].push_back(wek[i][j]);
    if (wek[i][j] > wek[i + 1][j])
      nsEdges.insert(pair<int, int>(wek[i][j], wek[i + 1][j]));
  }
  while (nsEdges.size() > 0) {
    vv = *(nsEdges.begin());
    nsEdges.erase(vv);
    a = vv.first;
    b = vv.second;
    if (a < b && !cont(a) && cont(b)) {
      zb.insert(a);
      for (i = 0; i < inEdges[a].size(); i++)
        nsEdges.insert(pair<int, int>(inEdges[a][i], a));
    } else if (a > b && cont(b)) {
      printf("No\n");
      return 0;
    } else if (a > b && !cont(a)) {
      zb.insert(a);
      for (i = 0; i < inEdges[a].size(); i++)
        nsEdges.insert(pair<int, int>(inEdges[a][i], a));
    }
  }
  printf("Yes\n");
  printf("%d\n", zb.size());
  for (it = zb.begin(); it != zb.end(); it++) printf("%d ", *it);
  if (zb.size() > 0) printf("\n");
  return 0;
}
