#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long N = 1e5 + 2;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;
int k, p[N];
bool used[N];
int n, m, x, y;
vector<pair<int, int> > D[N];
vector<int> f, V[N];
void dfs(int v) {
  used[v] = 1;
  for (auto to : D[v]) {
    int x = to.first;
    int y = to.second;
    int r = V[x][y];
    if (x == n) continue;
    int l = V[x + 1][y];
    if (p[x + 1] == y) {
      if (used[l]) l += m;
      if (used[r]) r += m;
      if (l < r) {
        if (l > m) {
          cout << "No";
          exit(0);
        }
        if (!used[l]) dfs(l);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> k;
    p[i] = -1;
    for (int j = 0; j < k; j++) {
      cin >> x;
      V[i].push_back(x);
      D[x].push_back({i, j});
    }
    if (i != 1) {
      x = V[i].size();
      y = V[i - 1].size();
      for (int j = 0; j < min(x, y); j++) {
        if (V[i][j] != V[i - 1][j]) {
          p[i] = j;
          break;
        }
      }
      if (x < y && p[i] == -1) {
        cout << "No";
        return 0;
      }
    }
  }
  for (int i = n; i > 1; i--) {
    x = p[i];
    if (x == -1) continue;
    int l = V[i][x];
    int r = V[i - 1][x];
    if (used[l]) l += m;
    if (used[r]) l += m;
    if (l < r) {
      if (l > m) {
        cout << "No";
        return 0;
      }
      if (!used[l]) dfs(l);
    }
  }
  for (int i = 1; i <= m; i++)
    if (!used[i]) f.push_back(i);
  cout << "Yes\n" << f.size() << endl;
  for (auto to : f) cout << to << " ";
}
