#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> ch, used;
vector<vector<long long> > a;
const long long N = 1e5 + 47;
vector<long long> g[N];
void createGraph(vector<long long>& a, vector<long long>& b) {
  for (long long i = 0; i < min(a.size(), b.size()); ++i) {
    if (a[i] != b[i]) {
      if (a[i] > b[i])
        ch[a[i]] = 1;
      else
        g[b[i]].push_back(a[i]);
      return;
    } else
      continue;
  }
}
void dfs(long long u) {
  used[u] = 1, ch[u] = 1;
  for (auto& to : g[u]) {
    if (!used[to]) dfs(to);
  }
}
bool isLess(vector<long long>& a, vector<long long>& b) {
  for (long long i = 0; i < min(a.size(), b.size()); ++i) {
    if (a[i] >= 0 && ch[a[i]]) a[i] -= m;
    if (b[i] >= 0 && ch[b[i]]) b[i] -= m;
    if (a[i] != b[i])
      return a[i] < b[i];
    else
      continue;
  }
  return a.size() <= b.size();
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(20);
  cin >> n >> m;
  a.resize(n);
  used.resize(m, 0);
  ch.resize(m, 0);
  for (auto& i : a) {
    long long k;
    cin >> k;
    i.resize(k);
    for (auto& j : i) cin >> j, --j;
  }
  for (long long i = 1; i < n; ++i) {
    createGraph(a[i - 1], a[i]);
  }
  for (long long i = 0; i < m; ++i) {
    if (!used[i] && ch[i]) dfs(i);
  }
  bool ok = 1;
  for (long long i = 1; i < n; ++i) {
    ok &= isLess(a[i - 1], a[i]);
  }
  if (ok) {
    long long ans = 0;
    for (auto& i : ch) ans += i;
    cout << "Yes\n";
    cout << ans << '\n';
    for (long long i = 0; i < m; ++i)
      if (ch[i]) cout << i + 1 << ' ';
  } else
    cout << "No";
}
