#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool op = 0;
  char c = getchar();
  while (!isdigit(c)) op |= (c == '-'), c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return op ? -x : x;
}
const int N = 100010;
int n, m, tot, cnt, sum;
int head[N * 2], to[N * 4], nxt[N * 4];
int low[N * 2], dfn[N * 2], scc[N * 2];
bool on[N * 2];
vector<int> a[N];
stack<int> s;
void addedge(int u, int v) {
  to[++tot] = v;
  nxt[tot] = head[u];
  head[u] = tot;
  return;
}
void tarjan(int u) {
  dfn[u] = low[u] = ++cnt;
  on[u] = true;
  s.push(u);
  for (int i = head[u]; i; i = nxt[i]) {
    if (dfn[to[i]] == 0) {
      tarjan(to[i]);
      low[u] = min(low[u], low[to[i]]);
    } else if (on[to[i]] == true)
      low[u] = min(low[u], dfn[to[i]]);
  }
  if (dfn[u] == low[u]) {
    scc[u] = ++sum;
    on[u] = false;
    while (s.top() != u) {
      int cur = s.top();
      s.pop();
      on[cur] = false;
      scc[cur] = sum;
    }
    s.pop();
  }
  return;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) {
    int k = read();
    a[i].resize(k);
    for (int j = 0; j < k; j++) {
      a[i][j] = read();
    }
  }
  for (int i = 1; i < n; i++) {
    bool flg = false;
    for (int j = 0; j < min(a[i].size(), a[i + 1].size()); j++) {
      int x = a[i][j], y = a[i + 1][j];
      if (x ^ y) {
        flg = true;
        if (x < y) {
          addedge(2 * y + 1, 2 * x + 1);
          addedge(2 * x, 2 * y);
        } else {
          addedge(2 * x, 2 * x + 1);
          addedge(2 * y + 1, 2 * y);
        }
        break;
      }
    }
    if (flg == false && a[i + 1].size() < a[i].size()) {
      printf("No");
      return 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (dfn[i * 2] == 0) tarjan(i * 2);
    if (dfn[i * 2 + 1] == 0) tarjan(i * 2 + 1);
  }
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    if (scc[i * 2] == scc[i * 2 + 1]) {
      printf("No");
      return 0;
    } else if (scc[i * 2 + 1] < scc[i * 2])
      cnt++;
  }
  printf("Yes\n%d\n", cnt);
  for (int i = 1; i <= m; i++) {
    if (scc[i * 2 + 1] < scc[i * 2]) {
      printf("%d ", i);
    }
  }
  return 0;
}
