#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int maxn = 2e5 + 10;
vector<int> vec[maxn], G[maxn], ans[maxn];
int x;
int dfn[maxn], sta[maxn], low[maxn], degree[maxn], belong[maxn], vis[maxn],
    pos[maxn];
int print[maxn], output[maxn];
int cnt, tot, scc, res;
void topo() {
  queue<int> s;
  for (int i = 1; i <= scc; ++i) {
    if (degree[i] == 0) s.push(i);
  }
  while (!s.empty()) {
    int u = s.front();
    if (print[u] == 0) {
      print[u] = 1;
      print[pos[u]] = 2;
    }
    s.pop();
    for (int i = 0; i < ans[u].size(); ++i) {
      int v = ans[u][i];
      degree[v]--;
      if (degree[v] == 0) s.push(v);
    }
  }
  res = 0;
  for (int i = 1; i <= m; ++i) {
    if (print[belong[i]] == 1) output[res++] = i;
  }
}
void tarjan(int u) {
  vis[u] = 1;
  dfn[u] = low[u] = cnt++;
  sta[++tot] = u;
  for (int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    if (vis[v] == 0) tarjan(v);
    if (vis[v] == 1) low[u] = min(low[u], low[v]);
  }
  if (low[u] == dfn[u]) {
    scc++;
    do {
      vis[sta[tot]] = -1;
      belong[sta[tot]] = scc;
    } while (sta[tot--] != u);
  }
}
int solve() {
  scc = 0;
  cnt = 1;
  tot = -1;
  for (int i = 1; i <= 2 * m; ++i) {
    if (vis[i] == 0) tarjan(i);
  }
  for (int i = 1; i <= m; ++i) {
    if (belong[i] == belong[i + m]) return 0;
    pos[belong[i]] = belong[i + m];
    pos[belong[i + m]] = belong[i];
  }
  for (int i = 1; i <= 2 * m; ++i) {
    for (int j = 0; j < G[i].size(); ++j) {
      int v = G[i][j];
      if (belong[i] != belong[v]) {
        degree[belong[i]]++;
        ans[belong[v]].push_back(belong[i]);
      }
    }
  }
  topo();
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &k);
    while (k--) {
      scanf("%d", &x);
      vec[i].push_back(x);
    }
  }
  bool ok = true;
  for (int i = 1; i <= n - 1; ++i) {
    bool flag = false;
    for (int j = 0; j < min(vec[i].size(), vec[i + 1].size()); ++j) {
      if (vec[i][j] == vec[i + 1][j])
        continue;
      else {
        flag = true;
        if (vec[i][j] < vec[i + 1][j]) {
          G[vec[i][j]].push_back(vec[i + 1][j]);
          G[vec[i + 1][j] + m].push_back(vec[i][j] + m);
        } else {
          G[vec[i][j]].push_back(vec[i + 1][j] + m);
          G[vec[i + 1][j]].push_back(vec[i][j] + m);
          G[vec[i][j]].push_back(vec[i + 1][j]);
          G[vec[i + 1][j] + m].push_back(vec[i][j] + m);
          G[vec[i][j] + m].push_back(vec[i + 1][j]);
          G[vec[i + 1][j] + m].push_back(vec[i][j]);
        }
        break;
      }
    }
    if (flag == false && vec[i].size() > vec[i + 1].size()) ok = false;
  }
  if (!ok)
    printf("No\n");
  else {
    int ans = solve();
    if (ans == 1) {
      printf("Yes\n");
      memset(vis, 0, sizeof(vis));
      for (int i = 0; i < res; ++i) vis[output[i]] = 1;
      vector<int> tmp;
      for (int i = 1; i <= m; ++i)
        if (vis[i] == 0) tmp.push_back(i);
      printf("%d\n", (int)tmp.size());
      for (int i = 0; i < tmp.size(); ++i) {
        printf("%d ", tmp[i]);
      }
      printf("\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}
