#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
std::vector<int> G[maxn * 2];
int n, m;
std::vector<int> vec[maxn];
bool flag = true;
int vis[maxn * 2];
void dfs(int u) {
  vis[u] = 1;
  for (auto v : G[u]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
}
bool cmp(int i, int j) {
  if (vis[i]) i = i - m;
  if (vis[j]) j = j - m;
  return i < j;
}
set<int> ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    while (k--) {
      int x;
      cin >> x;
      vec[i].push_back(x);
    }
  }
  memset((vis), (0), sizeof(vis));
  for (int i = 1; i < n; ++i) {
    int num = min(vec[i - 1].size(), vec[i].size());
    bool tmp = false;
    for (int j = 0; j < num; ++j) {
      if (vec[i - 1][j] != vec[i][j]) {
        if (vec[i - 1][j] > vec[i][j]) {
          ans.insert(vec[i - 1][j]);
        } else {
          G[vec[i][j]].push_back(vec[i - 1][j]);
        }
        tmp = true;
        break;
      }
    }
    if (!tmp && vec[i - 1].size() > vec[i].size()) flag = false;
  }
  for (auto e : ans) {
    dfs(e);
  }
  for (int i = 1; i < n; ++i) {
    int num = min(vec[i - 1].size(), vec[i].size());
    for (int j = 0; j < num; ++j) {
      if (vec[i - 1][j] != vec[i][j]) {
        if (!cmp(vec[i - 1][j], vec[i][j])) {
          flag = false;
          break;
        }
        break;
      }
    }
  }
  for (int i = 1; i <= m; ++i)
    if (vis[i]) ans.insert(i);
  if (!flag)
    std::cout << "No" << '\n';
  else {
    std::cout << "Yes" << '\n';
    std::cout << ans.size() << '\n';
    for (auto e : ans) {
      std::cout << e << ' ';
    }
  }
  return 0;
}
