#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, sz[N];
bool cap[N], vis[N];
vector<int> ans, arr[N], g[N];
void kill() {
  cout << "No";
  exit(0);
}
void dfs(int u) {
  vis[u] = 1;
  ans.push_back(u);
  for (auto &c : g[u])
    if (!vis[c]) dfs(c);
}
bool can() {
  for (int i = 0; i < n - 1; ++i) {
    int j = 0;
    while (j < min(sz[i], sz[i + 1]) && arr[i][j] == arr[i + 1][j]) ++j;
    if (j != sz[i]) {
      if (j == sz[i + 1])
        kill();
      else {
        if (arr[i][j] > arr[i + 1][j]) return 0;
      }
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> sz[i];
    arr[i].resize(sz[i]);
    for (int j = 0; j < sz[i]; ++j) cin >> arr[i][j];
  }
  for (int i = 0; i < n - 1; ++i) {
    int j = 0;
    while (j < min(sz[i], sz[i + 1]) && arr[i][j] == arr[i + 1][j]) ++j;
    if (j != sz[i]) {
      if (j == sz[i + 1])
        kill();
      else {
        if (arr[i][j] > arr[i + 1][j])
          cap[arr[i][j]] = 1;
        else
          g[arr[i + 1][j]].push_back(arr[i][j]);
      }
    }
  }
  for (int i = 1; i <= m; ++i)
    if (cap[i] && !vis[i]) dfs(i);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < sz[i]; ++j)
      if (vis[arr[i][j]]) arr[i][j] -= m;
  if (can()) {
    cout << "Yes\n" << ans.size() << '\n';
    for (auto &it : ans) cout << it << ' ';
  } else
    kill();
  return 0;
}
