#include <bits/stdc++.h>
using namespace std;
const int maxn = 2E5 + 20;
int n, m, dfs_clock, cnt, tot, ok, dfn[maxn], low[maxn], bel[maxn], Ans[maxn],
    G[maxn];
stack<int> stk;
vector<int> v[maxn], A[maxn];
void Tarjan(int x) {
  stk.push(x);
  dfn[x] = low[x] = ++dfs_clock;
  for (auto to : v[x]) {
    if (!dfn[to])
      Tarjan(to), low[x] = min(low[x], low[to]);
    else if (!bel[to])
      low[x] = min(low[x], dfn[to]);
  }
  if (dfn[x] == low[x]) {
    ++cnt;
    for (;;) {
      int tp = stk.top();
      stk.pop();
      bel[tp] = cnt;
      if (tp == x) break;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    for (int j = 0; j < x; j++) {
      int y;
      scanf("%d", &y);
      A[i].push_back(y);
    }
  }
  for (int i = 1; i < n; i++) {
    bool flag = 0;
    int t = min(A[i].size(), A[i + 1].size());
    for (int j = 0; j < t; j++) {
      if (A[i][j] == A[i + 1][j]) continue;
      if (A[i][j] < A[i + 1][j]) {
        v[((A[i][j]) << 1)].push_back(((A[i + 1][j]) << 1));
        v[((A[i + 1][j]) << 1) ^ 1].push_back(((A[i][j]) << 1) ^ 1);
      } else {
        v[((A[i][j]) << 1)].push_back(((A[i][j]) << 1) ^ 1);
        v[((A[i + 1][j]) << 1) ^ 1].push_back(((A[i + 1][j]) << 1));
        v[((A[i][j]) << 1) ^ 1].push_back(((A[i + 1][j]) << 1));
        v[((A[i + 1][j]) << 1)].push_back(((A[i][j]) << 1) ^ 1);
      }
      flag = 1;
      break;
    }
    if (!flag && A[i].size() > A[i + 1].size()) {
      puts("No");
      return 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (!dfn[((i) << 1)]) Tarjan(((i) << 1));
    if (!dfn[((i) << 1) ^ 1]) Tarjan(((i) << 1) ^ 1);
    if (bel[((i) << 1)] == bel[((i) << 1) ^ 1]) {
      puts("No");
      return 0;
    } else if (bel[((i) << 1)] > bel[((i) << 1) ^ 1])
      Ans[++tot] = i;
  }
  puts("Yes");
  cout << tot << endl;
  for (int i = 1; i <= tot; i++) printf("%d%c", Ans[i], i == tot ? '\n' : ' ');
  return 0;
}
