#include <bits/stdc++.h>
using namespace std;
const int N = 210000, M = 210000;
struct Edge {
  int u, v, nxt;
} e[M];
int head[N], en = 0;
inline void add(int x, int y) {
  e[++en].u = x;
  e[en].v = y;
  e[en].nxt = head[x];
  head[x] = en;
}
int dfn[N], low[N], num, tot, scc[N], st[N], top, id[N], cnt = 0;
bool ins[N];
void tarjan(int x) {
  dfn[x] = low[x] = ++num;
  ins[x] = true;
  st[++top] = x;
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].v;
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (ins[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] == low[x]) {
    int y;
    ++tot;
    do {
      y = st[top--];
      scc[y] = tot;
      ins[y] = false;
      id[y] = ++cnt;
    } while (x != y);
  }
}
int n, m, len[2], a[2][N], t = 1;
vector<int> ans;
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d", &len[0]);
  for (int i = 1; i <= len[0]; ++i) scanf("%d", &a[0][i]);
  for (int i = 2; i <= n; ++i, t ^= 1) {
    scanf("%d", &len[t]);
    for (int j = 1; j <= len[t]; ++j) scanf("%d", &a[t][j]);
    bool flag = false;
    for (int j = 1; j <= min(len[t], len[t ^ 1]); ++j)
      if (a[t ^ 1][j] != a[t][j]) {
        if (a[t ^ 1][j] < a[t][j])
          add(a[t ^ 1][j], a[t][j]), add(a[t][j] + m, a[t ^ 1][j] + m);
        else
          add(a[t ^ 1][j], a[t ^ 1][j] + m), add(a[t][j] + m, a[t][j]);
        flag = true;
        break;
      }
    if (!flag && len[t] < len[t ^ 1]) {
      puts("No");
      return 0;
    }
  }
  for (int i = 1; i <= m * 2; ++i)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; ++i)
    if (scc[i] == scc[i + m]) {
      puts("No");
      return 0;
    }
  for (int i = 1; i <= m; ++i)
    if (id[i + m] < id[i]) ans.push_back(i);
  puts("Yes");
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i]);
  return 0;
}
