#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
const int N = 100002;
int n, m, sz[N], indeg[N], value[N];
vector<int> arr[N], adj[N];
bool caps[N];
set<int> ans;
void solve() {}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &sz[i]);
    arr[i].resize(sz[i]);
    for (int j = 0; j < sz[i]; j++) scanf("%d", &arr[i][j]);
  }
  for (int i = 1; i <= m; i++) value[i] = i;
  for (int i = 1; i < n; i++) {
    int j = 0;
    for (j = 0;
         j < sz[i] && j < sz[i + 1] && value[arr[i][j]] == value[arr[i + 1][j]];
         j++)
      ;
    if (j == sz[i]) continue;
    if (j == sz[i + 1]) {
      printf("No\n");
      exit(0);
    }
    if (arr[i][j] < arr[i + 1][j]) adj[arr[i + 1][j]].push_back(arr[i][j]);
  }
  queue<int> qq;
  for (int i = 1; i < n; i++) {
    int j = 0;
    for (j = 0; j < sz[i] && j < sz[i + 1] && arr[i][j] == arr[i + 1][j]; j++)
      ;
    if (j == sz[i]) continue;
    if (j == sz[i + 1]) {
      printf("No\n");
      exit(0);
    }
    if (arr[i][j] > arr[i + 1][j]) {
      if (!caps[arr[i][j]]) {
        caps[arr[i][j]] = true;
        value[arr[i][j]] -= 1e6;
        ans.insert(arr[i][j]);
        qq.push(arr[i][j]);
      }
    }
  }
  while (!qq.empty()) {
    int v = qq.front();
    qq.pop();
    for (auto it : adj[v])
      if (!caps[it]) {
        caps[it] = true;
        value[it] -= 1e6;
        qq.push(it);
        ans.insert(it);
      }
  }
  for (int i = 1; i < n; i++) {
    int j = 0;
    for (j = 0;
         j < sz[i] && j < sz[i + 1] && value[arr[i][j]] == value[arr[i + 1][j]];
         j++)
      ;
    if (j == sz[i]) continue;
    if (j == sz[i + 1]) {
      printf("No\n");
      exit(0);
    }
    if (value[arr[i][j]] > value[arr[i + 1][j]]) {
      if (value[arr[i][j]] > value[arr[i + 1][j]]) {
        printf("No\n");
        exit(0);
      }
    }
  }
  printf("Yes\n%d\n", (int)ans.size());
  for (auto it : ans) printf("%d ", it);
  return 0;
}
