#include <bits/stdc++.h>
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")
const int MAXINT = 2147483640;
const long long MAXLL = 9223372036854775800LL;
const long long MAXN = 1000000;
const double pi = 3.1415926535897932384626433832795;
using namespace std;
long long f[500000];
long long f1[500000];
vector<long long> v[500000];
vector<long long> v1[500000];
void dfs(long long xx) {
  if (f1[xx]) return;
  f1[xx] = 1;
  f[xx] = 1;
  for (int j = 0; j < v1[xx].size(); j++) dfs(v1[xx][j]);
}
long long check(long long xx, long long yy) {
  long long n1 = v[xx].size();
  long long n2 = v[yy].size();
  for (int i = 0; i < min(n1, n2); i++)
    if (v[xx][i] > v[xx + 1][i])
      return 1;
    else if (v[xx][i] < v[xx + 1][i])
      return 0;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  srand(time(0));
  long long n, m, m1, a;
  long long n1, n2;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> m1;
    for (int j = 1; j <= m1; j++) {
      cin >> a;
      v[i].push_back(a);
    }
  }
  for (int i = 1; i < n; i++) {
    n1 = v[i].size();
    n2 = v[i + 1].size();
    long long l = 0;
    while (v[i][l] == v[i + 1][l] and l < min(n1, n2)) l++;
    if (l == n1) continue;
    if (l == n2 and n1 > n2) {
      cout << "No" << endl;
      return 0;
    }
    if (l != n2) {
      if (v[i][l] < v[i + 1][l])
        v1[v[i + 1][l]].push_back(v[i][l]);
      else {
        f[v[i][l]] = 1;
      }
    } else {
      if (v[i][l] == v[i + 1][l] and n1 > n2) {
        cout << "No" << endl;
        return 0;
      }
      if (v[i][l] < v[i + 1][l])
        v1[v[i + 1][l]].push_back(v[i][l]);
      else {
        f[v[i][l]] = 1;
      }
    }
  }
  for (int i = 1; i <= m; i++)
    if (f[i]) dfs(i);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++)
      if (f[v[i][j]]) v[i][j] -= 400000;
  }
  for (int i = 1; i < n; i++) {
    if (check(i, i + 1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++)
    if (f[i]) ans++;
  cout << "Yes" << endl;
  cout << ans << endl;
  for (int i = 1; i <= m; i++)
    if (f[i]) cout << i << " ";
  return 0;
}
