#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5;
vector<int> g[MAXN];
bool used[MAXN];
void dfs(int u) {
  used[u] = 1;
  for (auto v : g[u])
    if (!used[v]) dfs(v);
}
signed main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> arr(n);
  for (auto &vec : arr) {
    int l;
    cin >> l;
    vec.resize(l);
    for (auto &i : vec) cin >> i;
    vec.push_back(0);
  }
  vector<pair<int, int>> pr;
  set<int> ans;
  for (int i = 1; i < n; i++) {
    bool sw = 0;
    int l = min(arr[i].size(), arr[i - 1].size());
    for (int j = 0; j < l; j++) {
      g[arr[i][j]].push_back(arr[i - 1][j]);
      if (arr[i - 1][j] != arr[i][j]) {
        if (arr[i - 1][j] > arr[i][j]) pr.push_back({arr[i - 1][j], arr[i][j]});
        break;
      }
    }
  }
  for (auto i : pr)
    if (!used[i.first]) dfs(i.first);
  for (auto i : pr)
    if (used[i.second] || i.second == 0) return cout << "No", 0;
  for (int i = 1; i <= m; i++)
    if (used[i]) ans.insert(i);
  cout << "Yes\n" << ans.size() << "\n";
  for (auto &i : ans) cout << i << " ";
  return 0;
}
