#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
bool cap[N];
bool ncap[N];
bool vis[N];
vector<int> res;
vector<int> no[N];
vector<int> kno[N];
bool dfs(int s) {
  vis[s] = 1;
  bool ret = !ncap[s];
  for (auto it : kno[s]) {
    if (!vis[it]) {
      ret &= dfs(it);
    }
  }
  return ret;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int s;
    cin >> s;
    for (int j = 1; j <= s; ++j) {
      int x;
      cin >> x;
      no[i].push_back(x);
    }
  }
  for (int i = 1; i < n; ++i) {
    int k = min(no[i].size(), no[i + 1].size());
    for (int j = 0; j < min(no[i].size(), no[i + 1].size()); ++j) {
      if (no[i][j] != no[i + 1][j]) {
        k = j;
        if (no[i][j] < no[i + 1][j]) {
          kno[no[i + 1][j]].push_back(no[i][j]);
        } else {
          cap[no[i][j]] = 1;
          ncap[no[i + 1][j]] = 1;
        }
        break;
      }
    }
    if (k == min(no[i].size(), no[i + 1].size()) &&
        no[i].size() > no[i + 1].size()) {
      return cout << "No", 0;
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (!vis[i] && cap[i]) {
      if (!dfs(i)) {
        return cout << "No", 0;
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (vis[i]) {
      res.push_back(i);
    }
  }
  cout << "Yes\n" << res.size() << endl;
  for (auto it : res) {
    cout << it << ' ';
  }
}
