#include <bits/stdc++.h>
using namespace std;
pair<int, int> cmp(vector<int> foo, vector<int> bar) {
  int i;
  for (i = 0; i < min(foo.size(), bar.size()); i++) {
    if (foo[i] != bar[i]) break;
  }
  if (i >= foo.size())
    return {-1, -1};
  else if (i >= bar.size())
    return {-2, -2};
  else
    return {foo[i], bar[i]};
}
vector<char> cap;
vector<vector<int>> g;
vector<bool> used;
vector<int> ans;
void dfs(int v) {
  if (used[v]) return;
  used[v] = true;
  ans.push_back(v);
  if (cap[v] == 0) {
    cout << "No\n";
    exit(0);
  }
  for (auto u : g[v]) {
    if (!used[u]) dfs(u);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> word(n);
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    for (int j = 0; j < l; j++) {
      int x;
      cin >> x;
      word[i].push_back(x);
    }
  }
  g.resize(m + 1);
  cap.assign(m + 1, 2);
  for (int i = n - 1; i > 0; --i) {
    pair<int, int> resp = cmp(word[i - 1], word[i]);
    if (resp.first == -1)
      continue;
    else if (resp.first == -2) {
      cout << "No\n";
      exit(0);
    } else if (resp.first < resp.second) {
      g[resp.second].push_back(resp.first);
    } else {
      if (cap[resp.first] == 0 || cap[resp.second] == 1) {
        cout << "No\n";
        exit(0);
      }
      cap[resp.first] = 1;
      cap[resp.second] = 0;
    }
  }
  used.assign(m + 1, false);
  for (int let = 1; let <= m; let++) {
    if (cap[let] == 1) {
      dfs(let);
    }
  }
  cout << "Yes\n";
  cout << ans.size() << endl;
  for (auto v : ans) cout << v << " ";
  return 0;
}
