#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > v(n);
  for (int i = 0; i < n; i++) {
    int sz;
    cin >> sz;
    v[i].resize(sz);
    for (int j = 0; j < sz; j++) cin >> v[i][j];
  }
  vector<int> ans;
  vector<bool> large(m + 1), cant(m + 1);
  vector<int> adj[m + 1];
  auto get = [&](int n) {
    if (large[n]) return n - m;
    return n;
  };
  auto no = []() {
    cout << "No";
    exit(0);
  };
  function<void(int)> make_large = [&](int x) {
    if (large[x]) return;
    if (cant[x]) no();
    ans.push_back(x);
    large[x] = 1;
    while (adj[x].size()) {
      int child = adj[x].back();
      adj[x].pop_back();
      make_large(child);
    }
  };
  for (int i = 1; i < n; i++) {
    bool differ = 0;
    int nn = min(v[i].size(), v[i - 1].size());
    for (int j = 0; j < nn; j++) {
      int &a = v[i - 1][j], b = v[i][j];
      if (a != b) {
        differ = 1;
        int aa = get(a), bb = get(b);
        if (aa < bb) {
          if (large[a]) {
            if (!large[b] && b < a) {
              cant[b] = 1;
            }
          } else {
            adj[b].push_back(a);
          }
        } else {
          if (large[a]) {
            no();
          } else {
            if (large[b]) {
              if (a < b) {
                make_large(a);
              } else {
                no();
              }
            } else {
              cant[b] = 1;
              make_large(a);
            }
          }
        }
        break;
      }
    }
    if (!differ && v[i].size() < v[i - 1].size()) no();
  }
  cout << "Yes\n";
  cout << ans.size() << '\n';
  for (int x : ans) cout << x << ' ';
}
