#include <bits/stdc++.h>
using namespace std;
const double g = 10.0, eps = 1e-7;
const int N = 100000 + 10, maxn = sqrt(N) + 10, inf = 0x3f3f3f;
bool ca[N], no[N], f;
int sz[N];
vector<int> s[N];
vector<int> v[N];
void dfs(int u) {
  if (no[u]) {
    f = 1;
    return;
  } else
    ca[u] = 1;
  for (int i = 0; i < v[u].size() && !f; i++) {
    dfs(v[u][i]);
  }
}
void fuck(int p1, int p2) {
  if (p1 > p2) {
    if (!ca[p1] && !ca[p2]) {
      f = 0;
      dfs(p1);
      if (f) {
        puts("No");
        exit(0);
      } else
        no[p2] = 1;
    } else if (ca[p1] && !ca[p2]) {
      no[p2] = 1;
    } else {
      puts("No");
      exit(0);
    }
  } else {
    if (!ca[p1] && ca[p2]) {
      f = 0;
      dfs(p1);
      if (f) {
        puts("No");
        exit(0);
      }
    } else if (!ca[p1] && !ca[p2]) {
      v[p2].push_back(p1);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &sz[i]);
    s[i].clear();
    for (int j = 0; j < sz[i]; j++) {
      int a;
      scanf("%d", &a);
      s[i].push_back(a);
    }
  }
  for (int i = 2; i <= n; i++) {
    if (s[i] == s[i - 1])
      continue;
    else if (sz[i - 1] > sz[i]) {
      bool ok = 1;
      for (int j = 0; j < s[i].size(); j++) {
        if (s[i - 1][j] != s[i][j]) {
          fuck(s[i - 1][j], s[i][j]);
          ok = 0;
          break;
        }
      }
      if (ok) {
        puts("No");
        return 0;
      }
    } else if (sz[i - 1] <= sz[i]) {
      for (int j = 0; j < s[i - 1].size(); j++) {
        if (s[i - 1][j] != s[i][j]) {
          fuck(s[i - 1][j], s[i][j]);
          break;
        }
      }
    }
  }
  puts("Yes");
  v[0].clear();
  for (int i = 1; i <= m; i++)
    if (ca[i]) v[0].push_back(i);
  printf("%d\n", v[0].size());
  for (int i = 0; i < v[0].size(); i++) printf("%d ", v[0][i]);
  puts("");
  return 0;
}
