#include <bits/stdc++.h>
using namespace std;
int n;
int k, m;
int vis[100005];
vector<int> a[100005];
vector<int> v[100005];
int f[100005];
int flag;
void dfs(int x, int y) {
  if (f[x] == 1) return;
  f[x] = 1;
  for (int i = 0; i < a[x].size(); i++) {
    int z = a[x][i];
    if (vis[z] == -1 && y == 1) {
      flag = 1;
      return;
    } else {
      vis[z] = y;
      dfs(z, y);
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int l;
    scanf("%d", &l);
    for (int j = 1; j <= l; j++) {
      int s;
      scanf("%d", &s);
      v[i].push_back(s);
    }
  }
  flag = 0;
  for (int i = 2; i <= n; i++) {
    int j = 0;
    int size1 = v[i].size(), size2 = v[i - 1].size();
    while (j < size1 && j < size2 && v[i][j] == v[i - 1][j]) j++;
    if (j < size1 && j < size2) {
      if (v[i - 1][j] > v[i][j]) {
        if (vis[v[i - 1][j]] == -1) flag = 1;
        if (vis[v[i][j]] == 1) flag = 1;
        vis[v[i - 1][j]] = 1, vis[v[i][j]] = -1;
      } else
        a[v[i][j]].push_back(v[i - 1][j]);
    } else if (j == size1 && j < size2) {
      flag = 1;
    }
  }
  for (int i = m; i >= 1; i--) {
    if (flag) break;
    if (vis[i] == 1) {
      dfs(i, vis[i]);
    }
  }
  if (flag == 1)
    printf("No\n");
  else {
    printf("Yes\n");
    int cnt = 0;
    for (int i = 1; i <= m; i++) cnt += vis[i] == 1 ? 1 : 0;
    printf("%d\n", cnt);
    for (int i = 1; i <= m; i++) {
      if (vis[i] == 1) printf("%d ", i);
    }
  }
}
