#include <bits/stdc++.h>
using namespace std;
int color[200002];
int ned[200002];
int ntt[200002];
vector<int> ans, a[200002], g[200002];
void dfs(int u) {
  color[u] = true;
  for (int i = 0; i < g[u].size(); i++)
    if (!color[g[u][i]]) dfs(g[u][i]);
}
int n, m, i;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    int len;
    scanf("%d", &len);
    for (int j = 0; j < len; j++) {
      int x;
      scanf("%d", &x);
      a[i].push_back(x);
    }
  }
  for (i = 1; i < n; i++) {
    int st = 0;
    while (st < a[i].size() && st < a[i + 1].size() && a[i][st] == a[i + 1][st])
      st++;
    if (a[i].size() > a[i + 1].size() && st == a[i + 1].size()) {
      cout << "No" << endl;
      return 0;
    }
    if (st == a[i].size()) continue;
    if (a[i][st] < a[i + 1][st]) {
      g[a[i + 1][st]].push_back(a[i][st]);
      continue;
    }
    ned[a[i][st]] = true;
    ntt[a[i + 1][st]] = true;
  }
  for (i = 1; i <= m; i++)
    if (ned[i] && !color[i]) dfs(i);
  for (i = 1; i <= m; i++)
    if (color[i]) {
      ans.push_back(i);
      if (ntt[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
  cout << "Yes" << endl;
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  cout << endl;
}
