#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> v;
vector<int> graph[100001];
vector<int> res;
bool can = true;
void dfs(int cur) {
  for (auto next : graph[cur]) {
    if (res[next] == 0) can = false;
    if (res[next] == 1) continue;
    res[next] = 1;
    dfs(next);
  }
}
int main() {
  cin >> n >> m;
  v.resize(n);
  res.resize(m, -1);
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    v[i].resize(l);
    for (int j = 0; j < l; j++) {
      cin >> v[i][j];
      v[i][j]--;
    }
  }
  int plen = v[0].size();
  for (int i = 1; i < n; i++) {
    int len = v[i].size();
    for (int j = 0; j < min(len, plen); j++) {
      if (v[i - 1][j] < v[i][j]) {
        graph[v[i][j]].push_back(v[i - 1][j]);
        break;
      }
      if (v[i - 1][j] > v[i][j]) {
        if (res[v[i][j]] == 1) can = false;
        if (res[v[i - 1][j]] == 0) can = false;
        res[v[i][j]] = 0;
        res[v[i - 1][j]] = 1;
        break;
      }
    }
    plen = len;
  }
  for (int i = 0; i < m; i++) {
    if (res[i] == 1) dfs(i);
  }
  plen = v[0].size();
  for (int i = 1; i < n; i++) {
    int len = v[i].size();
    for (int j = 0; j < min(len, plen); j++) {
      int prev = v[i - 1][j];
      int cur = v[i][j];
      if (res[prev] == 1) prev -= 1e6;
      if (res[cur] == 1) cur -= 1e6;
      if (prev > cur) can = false;
      if (prev == cur && j == min(len, plen) - 1 && plen > len) can = false;
      if (prev == cur) continue;
      break;
    }
    plen = len;
  }
  if (can == false) {
    cout << "No";
    return 0;
  }
  int num = 0;
  for (int i = 0; i < m; i++) {
    if (res[i] == 1) num++;
  }
  cout << "Yes\n";
  cout << num << '\n';
  for (int i = 0; i < m; i++) {
    if (res[i] == 1) printf("%d ", i + 1);
  }
}
