#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const long long INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(tw) % (y - x + 1) + x;
}
const int MAXN = 1e5 + 5;
vector<int> graph[MAXN], graph2[MAXN];
int res[MAXN];
bool used[MAXN];
int dfs(int v, vector<int>* g, int c) {
  used[v] = true;
  if (res[v] == 1 - c) {
    cout << "No\n";
    exit(0);
  }
  res[v] = c;
  for (int to : g[v]) {
    if (!used[to]) {
      dfs(to, g, c);
    }
  }
  return 0;
}
int main() {
  cerr << fixed << setprecision(15);
  cout << fixed << setprecision(15);
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int>> inp;
  for (int i = 0; i < n; ++i) {
    int l;
    scanf("%d", &l);
    inp.push_back({});
    for (int j = 0; j < l; ++j) {
      int num;
      scanf("%d", &num);
      --num;
      inp.back().push_back(num);
    }
  }
  for (int i = 0; i < m; ++i) {
    res[i] = 2;
  }
  for (int i = 0; i < n - 1; ++i) {
    bool flag = false;
    for (int j = 0; j < min(((int)(inp[i]).size()), ((int)(inp[i + 1]).size()));
         ++j) {
      if (inp[i][j] != inp[i + 1][j]) {
        flag = true;
        if (inp[i][j] > inp[i + 1][j]) {
          if (res[inp[i][j]] == 1 || res[inp[i + 1][j]] == 0) {
            cout << "No\n";
            return 0;
          }
          res[inp[i][j]] = 0;
          res[inp[i + 1][j]] = 1;
        } else {
          graph[inp[i + 1][j]].push_back(inp[i][j]);
          graph2[inp[i][j]].push_back(inp[i + 1][j]);
        }
        break;
      }
    }
    if (!flag && ((int)(inp[i]).size()) > ((int)(inp[i + 1]).size())) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 0; i < m; ++i) {
    if (res[i] == 0 && !used[i]) {
      dfs(i, graph, res[i]);
    }
    if (res[i] == 1 && !used[i]) {
      dfs(i, graph2, res[i]);
    }
  }
  cout << "Yes\n";
  vector<int> ans;
  for (int i = 0; i < m; ++i) {
    if (res[i] == 0) {
      ans.push_back(i);
    }
  }
  cout << ((int)(ans).size()) << "\n";
  for (int num : ans) {
    cout << num + 1 << " ";
  }
  cout << "\n";
  return 0;
}
