#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> v;
vector<vector<int>> upward;
vector<int> res;
bool can = true;
void f(int idx, int l, int r) {
  if (!can) return;
  while (v[l].size() == idx && l < r) l++;
  if (l == r) return;
  for (int i = l; i <= r; i++) {
    if (v[i].size() <= idx) {
      can = false;
      return;
    }
  }
  int start = l, val = v[l][idx];
  for (int i = l + 1; i <= r; i++) {
    if (val != v[i][idx]) {
      f(idx + 1, start, i - 1);
      start = i;
      val = v[i][idx];
    }
  }
  f(idx + 1, start, r);
  int thres = -1;
  for (int i = l + 1; i <= r; i++) {
    if (v[i - 1][idx] > v[i][idx]) {
      if (thres != -1) {
        can = false;
        return;
      }
      thres = i;
    }
  }
  if (thres == -1) {
    vector<int> z;
    z.push_back(v[l][idx]);
    for (int i = l + 1; i <= r; i++) {
      if (z.back() != v[i][idx]) z.push_back(v[i][idx]);
    }
    upward.push_back(z);
    return;
  }
  for (int i = l; i < thres; i++) {
    if (res[v[i][idx]] == 0) {
      can = false;
      return;
    }
    res[v[i][idx]] = 1;
  }
  for (int i = thres; i <= r; i++) {
    if (res[v[i][idx]] == 1) {
      can = false;
      return;
    }
    res[v[i][idx]] = 0;
  }
}
int main() {
  cin >> n >> m;
  v.resize(n);
  res.resize(m, -1);
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    v[i].resize(l);
    for (int j = 0; j < l; j++) {
      cin >> v[i][j];
      v[i][j]--;
    }
  }
  f(0, 0, n - 1);
  vector<int> par(m, -1);
  for (int i = 0; i < upward.size(); i++)
    for (int j = 1; j < upward[i].size(); j++)
      par[upward[i][j]] = max(par[upward[i][j]], upward[i][j - 1]);
  for (int i = 0; i < m; i++) {
    if (res[i] == 1) {
      int cur = par[i];
      while (cur != -1) {
        if (res[cur] == 0) {
          can = false;
          break;
        }
        if (res[cur] == 1)
          break;
        else
          res[cur] = 1;
        cur = par[cur];
      }
    }
  }
  int num = 0;
  for (int i = 0; i < m; i++) {
    if (res[i] == 1) num++;
  }
  if (!can) {
    cout << "No";
    return 0;
  }
  cout << "Yes\n";
  printf("%d\n", num);
  for (int i = 0; i < m; i++) {
    if (res[i] == 1) printf("%d ", i + 1);
  }
}
