#include <bits/stdc++.h>
using namespace std;
vector<int> vec[100005];
bool vis[100005];
int p, len, ans, a, b;
int n, m, num;
bool ok = 0;
bool cmp(int x, int y) {
  if (vis[x] == 1 && vis[y] == 0) {
    p = 1;
    return true;
  }
  if (x <= y) {
    if (x < y) p = 1;
    return true;
  }
  return false;
}
void solve() {
  for (int i = n - 1; i >= 1; i--) {
    len = min(vec[i].size(), vec[i + 1].size());
    p = 0;
    for (int k = 0; k < len; k++) {
      a = vec[i][k], b = vec[i + 1][k];
      if ((vis[a] == 1 && vis[b] == 0) || (vis[a] == vis[b] && a < b)) {
        p = 1;
        break;
      } else if (vis[a] == vis[b] && a == b)
        ;
      else if (vis[a] == 1) {
        printf("No\n");
        return;
      } else {
        vis[a] = 1;
        if (vis[b] == 0 || a < b) {
          p = 1;
          break;
        } else if (a == b)
          ;
        else {
          printf("No\n");
          return;
        }
      }
    }
    if (p == 0) {
      if (vec[i].size() > vec[i + 1].size()) {
        {
          printf("No\n");
          return;
        }
      }
    }
  }
  if (ok == 0) {
    ok = 1;
    solve();
  } else {
    printf("Yes\n");
    ans = 0;
    for (int i = 0; i <= m; i++)
      if (vis[i] == 1) ans++;
    printf("%d\n", ans);
    for (int i = 0; i <= m; i++) {
      if (vis[i] == 1) {
        ans--;
        if (ans > 0)
          printf("%d ", i);
        else
          printf("%d\n", i);
      }
    }
  }
}
int main() {
  int tot;
  ok = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    vec[i].clear();
    scanf("%d", &tot);
    for (int j = 1; j <= tot; j++) {
      scanf("%d", &num);
      vec[i].push_back(num);
    }
  }
  solve();
  return 0;
}
