#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
vector<bool> big(100010 + 1), isBigger(100010 + 1), vis(100010);
vector<long long> g[100010], ans;
void done() {
  cout << "No";
  exit(0);
}
void dfs(long long u) {
  vis[u] = 1;
  ans.push_back(u);
  if (isBigger[u]) done();
  for (auto x : g[u]) {
    if (!vis[x]) {
      dfs(x);
    }
  }
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> v(n);
  for (auto &x : v) {
    long long sz;
    cin >> sz;
    x = vector<long long>(sz);
    for (auto &j : x) cin >> j;
  }
  auto checkLexic = [](vector<long long> &a, vector<long long> &b) {
    long long id = -1;
    for (long long i = 0; i < min(a.size(), b.size()); i++) {
      if (a[i] != b[i]) {
        id = i;
        break;
      }
    }
    if (id == -1 and a.size() > b.size()) done();
    if (id == -1) return;
    if (a[id] < b[id])
      g[b[id]].push_back(a[id]);
    else {
      big[a[id]] = 1;
      isBigger[b[id]] = 1;
    }
  };
  for (long long i = 1; i < n; i++) checkLexic(v[i - 1], v[i]);
  for (long long i = 1; i <= m; i++) {
    if (!vis[i] and big[i]) {
      dfs(i);
    }
  }
  cout << "Yes" << '\n';
  cout << ans.size() << '\n';
  for (auto x : ans) {
    cout << x << " ";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t = 1;
  while (t--) solve();
  return 0;
}
