#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 5;
struct Edge {
  int to, next;
} e[maxn << 1];
int n, m;
int head[maxn], idx;
vector<int> num[maxn];
int lens[maxn], ans[maxn];
struct two_SAT {
  int dfn[maxn], low[maxn];
  int s[maxn], top;
  int belong[maxn], cnt, num;
  bool vis[maxn];
  inline void init() {
    memset(head, -1, sizeof head);
    memset(belong, 0, sizeof belong);
    memset(dfn, 0, sizeof dfn);
    memset(vis, 0, sizeof vis);
    num = cnt = top = idx = 0;
  }
  inline void addedge(int u, int v) {
    e[idx].to = v;
    e[idx].next = head[u];
    head[u] = idx++;
  }
  void tarjan(int u) {
    dfn[u] = low[u] = ++num;
    vis[u] = 1;
    s[top++] = u;
    for (int i = head[u]; ~i; i = e[i].next) {
      int v = e[i].to;
      if (!dfn[v]) {
        tarjan(v);
        low[u] = min(low[u], low[v]);
      } else if (vis[v])
        low[u] = min(low[u], dfn[v]);
    }
    if (dfn[u] == low[u]) {
      while (1) {
        int v = s[--top];
        vis[v] = 0;
        belong[v] = cnt;
        if (u == v) break;
      }
      cnt++;
    }
  }
  inline bool solve() {
    for (int i = 2; i <= 2 * m + 1; i++)
      if (!dfn[i]) tarjan(i);
    for (int i = 2; i <= 2 * m; i += 2) {
      if (belong[i] == belong[i + 1]) return 0;
      ans[i >> 1] = belong[i] < belong[i + 1] ? i : i + 1;
    }
    return 1;
  }
} g;
int main() {
  g.init();
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &lens[i]);
    for (int j = 0; j < lens[i]; j++) {
      int x;
      scanf("%d", &x);
      num[i].push_back(x);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int pos = -1;
    int len = min(lens[i], lens[i + 1]);
    for (int j = 0; j < len; j++) {
      if (num[i][j] != num[i + 1][j]) {
        pos = j;
        break;
      }
    }
    if (pos == -1) {
      if (lens[i] <= lens[i + 1])
        continue;
      else {
        puts("No");
        exit(0);
      }
    }
    if (num[i][pos] > num[i + 1][pos]) {
      g.addedge(num[i][pos] << 1, num[i][pos] << 1 | 1);
      g.addedge(num[i + 1][pos] << 1 | 1, num[i + 1][pos] << 1);
    } else {
      g.addedge(num[i + 1][pos] << 1 | 1, num[i][pos] << 1 | 1);
      g.addedge(num[i][pos] << 1, num[i + 1][pos] << 1);
    }
  }
  if (g.solve()) {
    puts("Yes");
    int cnt = 0;
    for (int i = 1; i <= m; i++)
      if (ans[i] == (i << 1 | 1)) cnt++;
    printf("%d\n", cnt);
    for (int i = 1; i <= m; i++)
      if (ans[i] == (i << 1 | 1)) printf("%d ", i);
    puts("");
  } else
    puts("No");
  return 0;
}
