#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double num1, double bin) { return fabs(num1 - bin) < 1e-9; }
const int INF = 1 << 29;
template <class T>
void chmax(T& num1, const T& bin) {
  num1 = max(num1, bin);
}
template <class T>
void chmin(T& num1, const T& bin) {
  num1 = min(num1, bin);
}
long long modd = 1000000007;
vector<int> vip;
vector<bool> countAa;
int cc1[200002];
int finn[200002];
int ntt[200002];
int n, m;
vector<int> result, vv1[200002], vv2[200002];
void depth(int depp) {
  cc1[depp] = true;
  for (int i = 0; i < vv2[depp].size(); i++)
    if (!cc1[vv2[depp][i]]) depth(vv2[depp][i]);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int ll1;
    cin >> ll1;
    for (int j = 0; j < ll1; j++) {
      int x;
      cin >> x;
      vv1[i].push_back(x);
    }
  }
  for (int i = 1; i < n; i++) {
    int strr = 0;
    while (strr < vv1[i].size() && strr < vv1[i + 1].size() &&
           vv1[i][strr] == vv1[i + 1][strr])
      strr++;
    if (vv1[i].size() > vv1[i + 1].size() && strr == vv1[i + 1].size()) {
      cout << "No" << endl;
      return 0;
    }
    if (strr == vv1[i].size()) continue;
    if (vv1[i][strr] < vv1[i + 1][strr]) {
      vv2[vv1[i + 1][strr]].push_back(vv1[i][strr]);
      continue;
    }
    finn[vv1[i][strr]] = true;
    ntt[vv1[i + 1][strr]] = true;
  }
  for (int i = 1; i <= m; i++) {
    if (finn[i] && !cc1[i]) {
      depth(i);
    }
  }
  for (int i = 1; i <= m; i++)
    if (cc1[i]) {
      result.push_back(i);
      if (ntt[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
  cout << "Yes" << endl;
  cout << result.size() << endl;
  for (int i = 0; i < result.size(); i++) {
    cout << result[i] << " ";
  }
  cout << endl;
}
