#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int maxm = 4e5 + 10;
class TwoSAT {
 public:
  struct node {
    int to;
    int next;
  } edge[maxm];
  int head[maxn], tot;
  int low[maxn], dfn[maxn], Stack[maxn], Belong[maxn], num[maxn], topo[maxn];
  int index, top, sum;
  int scc, n;
  bool instack[maxn];
  void init(int n) {
    memset(head, -1, sizeof(head));
    memset(dfn, 0, sizeof(dfn));
    memset(instack, false, sizeof(instack));
    memset(num, 0, sizeof(num));
    index = scc = top = tot = sum = 0;
    this->n = n;
  }
  void addedge(int u, int v) {
    edge[tot].to = v;
    edge[tot].next = head[u];
    head[u] = tot++;
  }
  void tarjan(int u) {
    int v;
    low[u] = dfn[u] = ++index;
    Stack[top++] = u;
    instack[u] = true;
    for (int i = head[u]; i != -1; i = edge[i].next) {
      v = edge[i].to;
      if (!dfn[v]) {
        tarjan(v);
        if (low[u] > low[v]) low[u] = low[v];
      } else if (instack[v] && low[u] > dfn[v])
        low[u] = dfn[v];
    }
    if (low[u] == dfn[u]) {
      scc++;
      do {
        v = Stack[--top];
        instack[v] = false;
        Belong[v] = scc;
        num[scc]++;
        topo[v] = ++sum;
      } while (u != v);
    }
  }
  bool solve() {
    for (int i = 0; i < n; i++)
      if (!dfn[i]) tarjan(i);
    for (int i = 0; i < n; i += 2)
      if (Belong[i] == Belong[i ^ 1]) return false;
    return true;
  }
} sat;
vector<int> cnt[maxn];
int n, m;
void solve() {
  sat.init(2 * m);
  bool result = true;
  for (int i = 0; i < n - 1; i++) {
    bool flag = false;
    int len = min(cnt[i].size(), cnt[i + 1].size());
    for (int j = 0; j < len; j++) {
      int u = cnt[i][j];
      int v = cnt[i + 1][j];
      if (u != v) {
        --u, --v;
        if (u < v) {
          sat.addedge(u << 1 | 1, v << 1 | 1);
          sat.addedge(v << 1, u << 1);
        } else {
          sat.addedge(u << 1 | 1, u << 1);
          sat.addedge(v << 1, v << 1 | 1);
        }
        flag = true;
        break;
      }
    }
    if (!flag && cnt[i + 1].size() < cnt[i].size()) {
      result = false;
      break;
    }
  }
  if (!result || !sat.solve())
    cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    vector<int> ans;
    for (int i = 0; i < m << 1; i += 2)
      if (sat.topo[i] < sat.topo[i ^ 1]) ans.push_back((i >> 1) + 1);
    cout << ans.size() << endl;
    for (std::vector<int>::iterator s = ans.begin(); s != ans.end(); s++) {
      cout << *s << " ";
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int len;
    cin >> len;
    for (int j = 0; j < len; j++) {
      int x;
      cin >> x;
      cnt[i].push_back(x);
    }
  }
  solve();
  return 0;
}
