#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
vector<int> E[MAXN];
bool C[MAXN];
void dfs(int x) {
  if (C[x]) return;
  C[x] = true;
  for (int i = 0; i < E[x].size(); ++i) {
    int v = E[x][i];
    dfs(v);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a;
  vector<int> b;
  for (int i = 0; i < n; ++i) {
    int k;
    scanf("%d", &k);
    b.resize(k);
    for (int j = 0; j < k; ++j) {
      scanf("%d", &b[j]);
      --b[j];
    }
    int ms = min(a.size(), b.size());
    int j;
    for (j = 0; j < ms; ++j) {
      if (a[j] != b[j]) break;
    }
    if (j < ms) {
      E[b[j]].push_back(a[j]);
    } else if (a.size() > b.size()) {
      printf("No");
      return 0;
    }
    a = b;
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < E[i].size(); ++j) {
      int v = E[i][j];
      if (i < v) {
        if (!C[v]) dfs(v);
      }
    }
  }
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < E[i].size(); ++j) {
      int v = E[i][j];
      if (C[i] != C[v]) {
        if (!(C[v] && !C[i])) {
          printf("No");
          return 0;
        }
      } else if (v > i) {
        printf("No");
        return 0;
      }
    }
  vector<int> ans;
  for (int i = 0; i < m; ++i)
    if (C[i]) ans.push_back(i);
  printf("Yes\n%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i] + 1);
  return 0;
}
