#include <bits/stdc++.h>
using namespace std;
const long long int MOD = (long long int)1e9 + 7;
long long int powmod(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b = b >> 1;
  }
  return res % MOD;
}
vector<vector<long long int> > grph;
vector<long long int> vis, caps;
void dfs(long long int source) {
  vis[source] = 1;
  for (long long int i : grph[source]) {
    if (vis[i] == 0) {
      dfs(i);
      caps[i] = 1;
    }
  }
}
void solve(long long int testnum) {
  long long int n, m;
  cin >> n >> m;
  vector<vector<long long int> > ars;
  grph.resize(m + 1);
  vis.assign(m + 1, 0);
  caps.assign(m + 1, 0);
  for (long long int i = 0; i < n; i++) {
    long long int sz;
    cin >> sz;
    vector<long long int> temp;
    for (long long int j = 0; j < sz; j++) {
      long long int t;
      cin >> t;
      temp.push_back(t);
    }
    ars.push_back(temp);
  }
  for (long long int i = 0; i < n - 1; i++) {
    for (long long int j = 0; j < min((long long int)ars[i].size(),
                                      (long long int)ars[i + 1].size());
         j++) {
      if (ars[i][j] < ars[i + 1][j]) {
        grph[ars[i + 1][j]].push_back(ars[i][j]);
        break;
      } else if (ars[i][j] > ars[i + 1][j]) {
        caps[ars[i][j]] = 1;
        break;
      }
    }
  }
  for (long long int i = 1; i <= m; i++) {
    if (caps[i] == 1 && vis[i] == 0) {
      dfs(i);
    }
  }
  long long int check = 1;
  for (long long int i = 0; i < n - 1; i++) {
    for (long long int j = 0; j < min((long long int)ars[i].size(),
                                      (long long int)ars[i + 1].size());
         j++) {
      if (ars[i][j] + (1 - caps[ars[i][j]]) * m >
          ars[i + 1][j] + (1 - caps[ars[i + 1][j]]) * m) {
        check = 0;
        break;
      } else if (ars[i][j] + (1 - caps[ars[i][j]]) * m <
                 ars[i + 1][j] + (1 - caps[ars[i + 1][j]]) * m) {
        break;
      }
      if (j == min((long long int)ars[i].size(),
                   (long long int)ars[i + 1].size()) -
                   1 &&
          (long long int)ars[i].size() > (long long int)ars[i + 1].size()) {
        check = 0;
      }
    }
    if (check == 0) {
      break;
    }
  }
  if (check) {
    cout << "Yes\n";
    vector<long long int> res;
    for (long long int i = 1; i <= m; i++) {
      if (caps[i]) {
        res.push_back(i);
      }
    }
    cout << (long long int)res.size() << "\n";
    for (long long int i : res) {
      cout << i << " ";
    }
    cout << "\n";
  } else {
    cout << "No\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  for (long long int i = 1; i <= t; i++) {
    solve(i);
  }
}
