#include <bits/stdc++.h>
const int N = 100100;
using namespace std;
vector<int> s[N];
vector<int> adj[N];
bool isCapitalized[N];
void dfs(int u) {
  isCapitalized[u] = 1;
  for (int v : adj[u])
    if (!isCapitalized[v]) dfs(v);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int len;
    cin >> len;
    s[i].resize(len);
    int j = 0;
    while (len--) cin >> s[i][j++];
  }
  vector<int> capitalize;
  for (int i = 1; i < n; i++) {
    int till = min((int)s[i - 1].size(), (int)s[i].size());
    for (int j = 0; j < till; j++) {
      if (s[i - 1][j] == s[i][j]) continue;
      if (s[i - 1][j] > s[i][j])
        capitalize.push_back(s[i - 1][j]);
      else
        adj[s[i][j]].push_back(s[i - 1][j]);
      break;
    }
  }
  for (int u : capitalize) {
    if (isCapitalized[u]) continue;
    dfs(u);
  }
  for (int i = 1; i < n; i++) {
    int till = min((int)s[i - 1].size(), (int)s[i].size());
    for (int j = 0; j < till; j++) {
      if (s[i - 1][j] == s[i][j]) continue;
      if (s[i - 1][j] > s[i][j]) {
        if (!isCapitalized[s[i - 1][j]] || isCapitalized[s[i][j]]) {
          cout << "No\n";
          return 0;
        }
      } else {
        if (isCapitalized[s[i][j]] && !isCapitalized[s[i - 1][j]]) {
          cout << "No\n";
          return 0;
        }
      }
      break;
    }
  }
  for (int i = 1; i < n; i++) {
    int till = min((int)s[i - 1].size(), (int)s[i].size());
    int j;
    for (j = 0; j < till; j++)
      if (s[i - 1][j] != s[i][j]) break;
    if (j != till) continue;
    if (s[i - 1].size() > s[i].size()) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  int cnt = 0;
  for (int i = 1; i <= m; i++)
    if (isCapitalized[i]) cnt++;
  cout << cnt << '\n';
  for (int i = 1; i <= m; i++)
    if (isCapitalized[i]) cout << i << ' ';
  cout << '\n';
  return 0;
}
