#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
vector<vector<int>> g;
vector<int> vis, cap;
void dfs(int s) {
  vis[s] = 1;
  cap[s] = 1;
  for (int i : g[s]) {
    if (vis[i] == 0) {
      dfs(i);
    }
  }
}
int32_t main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  }
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n);
  g.resize(m + 1);
  vis.assign(m + 1, 0);
  cap.assign(m + 1, 0);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    a[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i < n; i++) {
    int k0 = a[i - 1].size(), k1 = a[i].size();
    int j = 0, f = 0;
    while (j < k0 and j < k1) {
      if (a[i - 1][j] == a[i][j]) {
        j++;
        continue;
      }
      f = 1;
      if (a[i - 1][j] < a[i][j]) {
        g[a[i][j]].push_back(a[i - 1][j]);
      } else {
        cap[a[i - 1][j]] = 1;
      }
      break;
    }
    if (f == 0) {
      if (a[i].size() < a[i - 1].size()) {
        cout << "No";
        return 0;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (vis[i] == 0 and cap[i] == 1) {
      dfs(i);
    }
  }
  for (int i = 1; i < n; i++) {
    int k0 = a[i - 1].size(), k1 = a[i].size();
    int j = 0;
    while (j < k0 and j < k1) {
      if (a[i - 1][j] == a[i][j]) {
        j++;
        continue;
      }
      if (a[i - 1][j] < a[i][j]) {
        if (cap[a[i][j]] == 1 and cap[a[i - 1][j]] != 1) {
          cout << "No";
          return 0;
        }
      } else {
        if (cap[a[i][j]] == 1) {
          cout << "No";
          return 0;
        }
      }
      break;
    }
  }
  {
    cout << "Yes\n";
    vector<int> ans;
    for (int i = 1; i <= m; i++) {
      if (cap[i] == 1) {
        ans.push_back(i);
      }
    }
    cout << ans.size() << "\n";
    for (int i : ans) {
      cout << i << " ";
    }
  }
  return 0;
}
