#include <bits/stdc++.h>
using namespace std;
vector<int> words[2];
bool needtobereduced[100100];
bool cannotbereduced[100100];
bool isreduced[100100];
bool impossible = false;
set<int> neighbours[100100];
int n, m;
int noww = 0, prevv = 1;
void dfs(int v) {
  isreduced[v] = true;
  for (auto to : neighbours[v]) {
    if (isreduced[to]) continue;
    dfs(to);
  }
}
void readword() {
  words[noww].clear();
  int l;
  scanf("%d", &l);
  for (int i = 0; i < l; i++) {
    int temp;
    scanf("%d", &temp);
    words[noww].push_back(temp);
  }
  return;
}
void resolveconflict() {
  bool wasdifferentletter = false;
  for (int i = 0; i < min(words[noww].size(), words[prevv].size()); i++) {
    if (words[noww][i] == words[prevv][i]) continue;
    wasdifferentletter = true;
    if (words[noww][i] < words[prevv][i]) {
      needtobereduced[words[prevv][i]] = true;
      cannotbereduced[words[noww][i]] = true;
    } else {
      neighbours[words[noww][i]].insert(words[prevv][i]);
    }
    break;
  }
  if (!wasdifferentletter) {
    if (words[noww].size() < words[prevv].size()) impossible = true;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  noww = 1;
  readword();
  noww = 0;
  for (int i = 0; i < n - 1; i++) {
    readword();
    resolveconflict();
    swap(noww, prevv);
  }
  for (int i = 1; i <= m; i++) {
    if (needtobereduced[i]) dfs(i);
  }
  vector<int> result;
  for (int i = 1; i <= m && !impossible; i++) {
    if (cannotbereduced[i] && isreduced[i]) impossible = true;
    if (isreduced[i]) result.push_back(i);
  }
  if (impossible) {
    printf("No");
    return 0;
  }
  printf("Yes\n%d\n", result.size());
  for (int i = 0; i < result.size(); i++) {
    printf("%d ", result[i]);
  }
  return 0;
}
