#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int sz = 1e5 + 10;
vector<int> G[sz], ve[sz], ans;
int ar[sz], cap[sz], vis[sz];
int n, m, fl;
void dfs(int u) {
  vis[u] = 1;
  for (int v : G[u]) {
    if (!vis[v]) dfs(v);
  }
}
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < sz; i++) {
      G[i].clear();
      ve[i].clear();
      ar[i] = 0;
      cap[i] = 0;
      vis[i] = 0;
    }
    ans.clear();
    fl = 1;
    for (int i = 0; i < n; i++) {
      int len;
      cin >> len;
      ve[i].clear();
      for (int j = 0, x; j < len; j++) {
        cin >> x;
        ve[i].push_back(x);
      }
    }
    for (int i = 1; i < n; i++) {
      int ind = 0;
      while (ind < ve[i - 1].size() && ind < ve[i].size() &&
             ve[i - 1][ind] == ve[i][ind]) {
        ind++;
      }
      if (ind == ve[i - 1].size()) continue;
      if (ve[i - 1].size() > ve[i].size() && ind == ve[i].size()) {
        fl = 0;
        break;
      }
      if (ve[i - 1][ind] < ve[i][ind]) {
        G[ve[i][ind]].push_back(ve[i - 1][ind]);
        continue;
      }
      cap[ve[i - 1][ind]] = ar[ve[i][ind]] = 1;
    }
    for (int i = 1; i <= m; i++) {
      if (cap[i] && !vis[i]) {
        dfs(i);
      }
    }
    for (int i = 1; i <= m; i++) {
      if (vis[i]) {
        if (ar[i])
          fl = 0;
        else
          ans.push_back(i);
      }
    }
    if (!fl)
      cout << "No\n";
    else {
      cout << "Yes\n";
      cout << ans.size() << "\n";
      for (int x : ans) cout << x << " ";
      cout << "\n";
    }
  }
  return 0;
}
