#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
vector<int> s[maxn];
bool Big[maxn];
int flag[maxn];
int n, m;
vector<int> pointa[maxn];
void Debug() {
  for (int i = 1; i <= m; i++) printf("%d\n", flag[i]);
}
bool check_min(int x) {
  int len1 = s[x].front();
  int len2 = s[x + 1].front();
  if (len2 < len1) {
    bool f = false;
    for (int i = 1; i <= len2; ++i) {
      if (flag[s[x][i]]) s[x][i] = s[x][i] - m;
      if (flag[s[x + 1][i]]) s[x + 1][i] = s[x + 1][i] - m;
      if (s[x][i] > s[x + 1][i])
        return false;
      else if (s[x][i] < s[x + 1][i])
        return true;
    }
    return false;
  } else {
    bool f = false;
    for (int i = 1; i <= len1; ++i) {
      if (flag[s[x][i]]) s[x][i] = s[x][i] - m;
      if (flag[s[x + 1][i]]) s[x + 1][i] = s[x + 1][i] - m;
      if (s[x][i] < s[x + 1][i])
        return true;
      else if (s[x][i] > s[x + 1][i])
        return false;
    }
    return true;
  }
}
int main() {
  bool over = false;
  memset(flag, 0, sizeof(flag));
  memset(Big, false, sizeof(Big));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    int len;
    scanf("%d", &len);
    s[i].push_back(len);
    for (int j = 1; j <= len; j++) {
      int x;
      scanf("%d", &x);
      s[i].push_back(x);
    }
  }
  for (int i = 1; i < n; ++i) {
    int len1 = s[i].front();
    int len2 = s[i + 1].front();
    for (int j = 1; j <= len1; ++j) {
      if (j > len2) {
        break;
      }
      if (s[i][j] == s[i + 1][j])
        continue;
      else {
        if (s[i][j] < s[i + 1][j]) {
          pointa[s[i + 1][j]].push_back(s[i][j]);
        } else
          flag[s[i][j]] = 1;
        break;
      }
    }
  }
  for (int i = m; i >= 1; --i) {
    if (!flag[i]) continue;
    while (!pointa[i].empty()) {
      int x = pointa[i].back();
      flag[x] = 1;
      pointa[i].pop_back();
    }
  }
  for (int i = 1; i < n; i++) {
    if (!check_min(i)) over = true;
  }
  if (over)
    printf("No\n");
  else {
    printf("Yes\n");
    int cnt = 0;
    for (int i = 1; i <= m; i++)
      if (flag[i]) cnt++;
    printf("%d\n", cnt);
    for (int i = 1; i <= m; ++i) {
      if (flag[i]) printf("%d ", i);
    }
    if (!cnt) putchar('\n');
  }
  return 0;
}
