#include <bits/stdc++.h>
const int MAXN = 200005;
using namespace std;
int N, M, vis[MAXN], scc[MAXN];
vector<int> str[MAXN], stk, G[MAXN], Gr[MAXN];
bool choose[MAXN];
void bye() {
  cout << "No\n";
  exit(EXIT_SUCCESS);
}
void dfs(int v) {
  vis[v] = true;
  for (int to : G[v]) {
    if (!vis[to]) {
      dfs(to);
    }
  }
  stk.push_back(v);
}
void rdfs(int v) {
  for (int to : Gr[v]) {
    if (scc[to] == 0) {
      scc[to] = scc[v];
      rdfs(to);
    }
  }
}
void get_scc() {
  for (int i = 0; i < 2 * M; i++) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  int cur = 1;
  for (int i = 2 * M - 1; i >= 0; i--) {
    if (scc[stk[i]] == 0) {
      scc[stk[i]] = cur++;
      rdfs(stk[i]);
    }
  }
}
void imply(int a, int b) {
  G[a].push_back(b);
  Gr[b].push_back(a);
}
int compare(const vector<int> &a, const vector<int> &b) {
  for (int i = 0; i < min(a.size(), b.size()); i++) {
    if (a[i] != b[i]) {
      return i;
    }
  }
  return min(a.size(), b.size());
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int sz;
    cin >> sz;
    str[i].resize(sz);
    for (int j = 0; j < sz; j++) {
      cin >> str[i][j];
      str[i][j]--;
    }
  }
  for (int i = 1; i < N; i++) {
    int diff = compare(str[i - 1], str[i]);
    if (diff == str[i - 1].size()) {
      continue;
    } else if (diff == str[i].size()) {
      bye();
    } else if (str[i - 1][diff] < str[i][diff]) {
      int a = str[i - 1][diff], b = str[i][diff];
      imply(a + M, b + M);
      imply(b, a);
    } else if (str[i - 1][diff] > str[i][diff]) {
      int a = str[i - 1][diff], b = str[i][diff];
      imply(a + M, a);
      imply(b, b + M);
    }
  }
  vector<int> ans;
  get_scc();
  for (int i = 0; i < M; i++) {
    if (scc[i] == scc[i + M]) {
      bye();
    }
    if (scc[i + M] < scc[i]) {
      ans.push_back(i);
    }
  }
  cout << "Yes\n";
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1 << (i + 1 < ans.size() ? ' ' : '\n');
  }
  return 0;
}
