#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > adj(500005);
long long n, m;
vector<vector<long long> > ar(500005);
long long sz[500005];
long long wr[500005];
long long vis[500005];
vector<long long> need;
vector<long long> ans;
void dfs(long long first) {
  if (vis[first]) return;
  vis[first] = 1;
  ans.push_back(first);
  if (wr[first]) {
    cout << "No";
    exit(0);
  }
  for (auto ch : adj[first]) {
    if (!vis[ch]) dfs(ch);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> sz[i];
    ar[i].resize(sz[i]);
    for (long long j = 0; j < sz[i]; j++) cin >> ar[i][j];
  }
  for (long long i = 1; i < n; i++) {
    long long fl = 0;
    for (long long j = 0; j < min(sz[i], sz[i - 1]); j++) {
      if (ar[i][j] == ar[i - 1][j]) {
        continue;
      }
      if (ar[i][j] > ar[i - 1][j]) {
        adj[ar[i][j]].push_back(ar[i - 1][j]);
        fl = 1;
        break;
      }
      need.push_back(ar[i - 1][j]);
      wr[ar[i][j]] = 1;
      fl = 1;
      break;
    }
    if (fl == 0 && sz[i] < sz[i - 1]) {
      cout << "No";
      return 0;
    }
  }
  for (auto j : need) {
    if (!vis[j]) dfs(j);
  }
  cout << "Yes\n";
  if (ans.empty()) {
    cout << "0\n";
  } else {
    cout << (long long)ans.size() << "\n";
    for (auto j : ans) cout << j << " ";
  }
  return 0;
}
