#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const long long inf = (long long)1e18 + 1;
const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
int n, m, len[N], can[N], used[N];
vector<int> s[N], path;
inline void boost() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
inline void Solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> len[i];
    s[i].resize(len[i]);
    for (int j = 0; j < len[i]; j++) cin >> s[i][j];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < min(len[i], len[i + 1]); j++) {
      if (s[i][j] > s[i + 1][j]) {
        used[s[i][j]] = 1;
        break;
      }
      if (s[i][j] < s[i + 1][j]) break;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < min(len[i], len[i + 1]); j++) {
      if (used[s[i][j]] != used[s[i + 1][j]] || s[i][j] != s[i + 1][j]) {
        if (s[i][j] <= s[i + 1][j] && used[s[i + 1][j]]) {
          used[s[i][j]] = 1;
        }
        break;
      }
    }
  }
  for (int i = 1; i <= m; i++) can[i] = !used[i];
  for (int z = 1; z <= 100; z++) {
    for (int i = n - 1; i >= 1; i--) {
      bool ok = 0;
      for (int j = 0; j < min(len[i], len[i + 1]); j++) {
        if (!((used[s[i][j]] != used[s[i + 1][j]] || s[i][j] != s[i + 1][j])))
          continue;
        if (used[s[i][j]]) {
          if (used[s[i + 1][j]] && s[i][j] > s[i + 1][j]) cout << "No", exit(0);
        } else {
          if (used[s[i + 1][j]] || s[i][j] > s[i + 1][j])
            used[s[i][j]] = 1, can[s[i][j]] = 0;
          if (used[s[i + 1][j]] && s[i][j] > s[i + 1][j]) cout << "No", exit(0);
        }
        ok = 1;
        break;
      }
      if (!ok && len[i] > len[i + 1]) {
        bool res = 0;
        for (int j = 0; j < len[i + 1]; j++) {
          if (can[s[i][j]]) {
            used[s[i][j]] = 1, res = 1, can[s[i][j]] = 0;
            break;
          }
        }
        if (!res) cout << "No", exit(0);
      }
    }
  }
  for (int i = 1; i <= m; i++)
    if (used[i]) path.push_back(i);
  cout << "Yes\n";
  cout << (int)path.size() << '\n';
  for (auto it : path) cout << it << ' ';
}
signed main() {
  boost();
  int tt = 1;
  while (tt--) {
    Solve();
  }
  return 0;
}
