#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 1;
bool vis[N], ans[N];
int n, m;
vector<int> s[N], adj[N];
int findiff(vector<int>& a, vector<int>& b) {
  int k = -1;
  for (int i = 0; i < min(a.size(), b.size()); i++) {
    if (a[i] != b[i]) {
      k = i;
      break;
    }
  }
  if (k == -1 && a.size() > b.size()) {
    return -69;
  }
  return k;
}
void dfs(int v) {
  vis[v] = 1;
  for (auto u : adj[v]) {
    if (ans[v]) {
      ans[u] = 1;
    }
    if (!vis[u]) {
      dfs(u);
    }
  }
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1, k; i <= n; i++) {
    cin >> k;
    while (k--) {
      int x;
      cin >> x;
      s[i].push_back(x);
    }
  }
  for (int i = 2; i <= n; i++) {
    int k = findiff(s[i - 1], s[i]);
    if (k == -69) {
      return cout << "No", 0;
    }
    if (k == -1) {
      continue;
    }
    if (s[i - 1][k] > s[i][k]) {
      ans[s[i - 1][k]] = 1;
    } else {
      adj[s[i][k]].push_back(s[i - 1][k]);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (ans[i] && !vis[i]) {
      dfs(i);
    }
  }
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    if (ans[i]) {
      cnt++;
    }
  }
  bool no = 0;
  for (int i = 2; i <= n; i++) {
    int k = findiff(s[i - 1], s[i]);
    if (k == -1) {
      continue;
    }
    if (ans[s[i - 1][k]]) {
      if (ans[s[i][k]]) {
        if (s[i - 1][k] > s[i][k]) {
          no = 1;
          break;
        }
      }
    } else {
      if (ans[s[i][k]]) {
        no = 1;
        break;
      } else {
        if (s[i - 1][k] > s[i][k]) {
          no = 1;
          break;
        }
      }
    }
  }
  if (no) {
    cout << "No";
    return 0;
  }
  cout << "Yes\n" << cnt << '\n';
  for (int i = 1; i <= m; i++) {
    if (ans[i]) {
      cout << i << ' ';
    }
  }
}
