#include <bits/stdc++.h>
using namespace std;
vector<int> p[100500];
vector<int> graph[100500];
bool light[100500];
vector<int> ans;
void dfs(int v) {
  light[v] = true;
  ans.push_back(v);
  for (int i : graph[v]) {
    if (!light[i]) {
      dfs(i);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  fill(light, light + 100500, false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int l;
    scanf("%d", &l);
    for (int j = 0; j < l; j++) {
      int x;
      scanf("%d", &x);
      p[i].push_back(x);
    }
  }
  deque<int> graphDeq1;
  vector<int> graphDeq2;
  for (int i = 0; i < n - 1; i++) {
    int l1 = p[i].size();
    int l2 = p[i + 1].size();
    int mnL = min(l1, l2);
    bool y = false;
    for (int j = 0; j < mnL; j++) {
      if (p[i][j] != p[i + 1][j]) {
        if (p[i][j] > p[i + 1][j]) {
          graphDeq1.push_back(p[i][j]);
          if (!light[p[i][j]]) ans.push_back(p[i][j]);
          light[p[i][j]] = true;
          graphDeq2.push_back(p[i + 1][j]);
        } else if (p[i][j] < p[i + 1][j]) {
          graph[p[i + 1][j]].push_back(p[i][j]);
        }
        y = true;
        break;
      }
    }
    if (!y) {
      if (l1 > l2) {
        printf("No");
        return 0;
      }
    }
  }
  while (!graphDeq1.empty()) {
    int i = graphDeq1.front();
    graphDeq1.pop_front();
    for (int to : graph[i]) {
      if (!light[to]) {
        light[to] = true;
        ans.push_back(to);
        graphDeq1.push_back(to);
      }
    }
  }
  for (int checking : graphDeq2) {
    if (light[checking]) {
      printf("No");
      return 0;
    }
  }
  printf("Yes\n%d\n", ans.size());
  for (int i : ans) {
    printf("%d ", i);
  }
}
