func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int is0(int d) { return d << 1; }   int is1(int d) { return d << 1 | 1; }   struct TwoSat {     static const int N = ::N << 1;     vector<int> G[N];     int pre[N], dfn[N], dfs_clock;     int scc[N], sccn;     int mark[N], n;     stack<int> S;     void init(int _n) {       for (int i = ((n = _n << 1)) - 1; i >= (0); --i) G[i].clear();     }     void addAnd(int a) { G[a ^ 1].push_back(a); }     void addThen(int a, int b) {       G[a].push_back(b);       G[b ^ 1].push_back(a ^ 1);     }     void addOr(int a, int b) {       G[a ^ 1].push_back(b);       G[b ^ 1].push_back(a);     }     void addXor(int a, int b) {       G[a].push_back(b ^ 1);       G[a ^ 1].push_back(b);       G[b].push_back(a ^ 1);       G[b ^ 1].push_back(a);     }     void dfs(int u) {       pre[u] = dfn[u] = ++dfs_clock;       S.push(u);       for (int _v = (0); _v < (((int)(G[u]).size())); ++_v) {         int v = G[u][_v];         if (!pre[v]) {           dfs(v);           dfn[u] = min(dfn[u], dfn[v]);         } else if (!scc[v])           dfn[u] = min(dfn[u], pre[v]);       }       if (pre[u] == dfn[u]) {         sccn++;         while (1) {           int x = S.top();           S.pop();           scc[x] = sccn;           if (x == u) break;         }       }     }     void find() {       dfs_clock = sccn = 0;       fill(pre, pre + n, 0);       fill(scc, scc + n, 0);       for (int i = (0); i < (n); ++i)         if (!pre[i]) dfs(i);     }     bool solve() {       find();       for (int i = 0; i < n; i += 2) {         if (scc[i] == scc[i + 1]) return false;         mark[i >> 1] = (scc[i] > scc[i + 1]);       }       return true;     }   } G;   int n, m;   vector<int> s[N];   pair<int, int> diff(vector<int> &a, vector<int> &b) {     int L = min(((int)(a).size()), ((int)(b).size()));     for (int i = (0); i < (L); ++i)       if (a[i] != b[i]) return make_pair(a[i], b[i]);     return make_pair(-1, -1);   }   void solve() {     G.init(m);     for (int i = (0); i < (n - 1); ++i) {       pair<int, int> r = diff(s[i], s[i + 1]);       if (!~r.first && ((int)(s[i]).size()) > ((int)(s[i + 1]).size())) {         puts( No );         return;       }       if (~r.first) {         if (r.first > r.second) {           G.addAnd(is1(r.first));           G.addAnd(is0(r.second));         } else {           G.addThen(is1(r.second), is1(r.first));         }       }     }     if (G.solve()) {       puts( Yes );       vector<int> ans;       for (int i = (0); i < (m); ++i)         if (G.mark[i]) ans.push_back(i + 1);       printf( %d n , ((int)(ans).size()));       for (int i = (0); i < (((int)(ans).size())); ++i)         printf( %d%c , ans[i],    n [i == ((int)(ans).size()) - 1]);     } else {       puts( No );     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = (0); i < (n); ++i) {       int li;       scanf( %d , &li);       for (int j = (0); j < (li); ++j) {         int x;         scanf( %d , &x);         s[i].push_back(x - 1);       }     }     solve();     return 0;   }   