#include using namespace std; template struct disjoint_set{ int n, _classes; vector p; disjoint_set(int n): n(n), _classes(n), p(n, -1){ } int make_set(){ p.push_back(-1); ++ _classes; return n ++; } int classes() const{ return _classes; } int root(int u){ return p[u] < 0 ? u : p[u] = root(p[u]); } bool share(int a, int b){ return root(a) == root(b); } int size(int u){ return -p[root(u)]; } bool merge(int u, int v){ u = root(u), v = root(v); if(u == v) return false; -- _classes; if constexpr(Enable_small_to_large) if(p[u] > p[v]) swap(u, v); p[u] += p[v], p[v] = u; return true; } bool merge(int u, int v, auto act){ u = root(u), v = root(v); if(u == v) return false; -- _classes; bool swapped = false; if constexpr(Enable_small_to_large) if(p[u] > p[v]) swap(u, v), swapped = true; p[u] += p[v], p[v] = u; act(u, v, swapped); return true; } void clear(){ _classes = n; fill(p.begin(), p.end(), -1); } vector> group_up(){ vector> g(n); for(auto i = 0; i < n; ++ i) g[root(i)].push_back(i); g.erase(remove_if(g.begin(), g.end(), [&](auto &s){ return s.empty(); }), g.end()); return g; } }; int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); int n, m; cin >> n >> m; disjoint_set dsu(n << 1); for(auto i = 0; i < m; ++ i){ int u, v; string type; cin >> u >> type >> v, -- u, -- v; for(auto t = 0; t < 2; ++ t){ dsu.merge(u << 1 | t, v << 1 | (t ^ (type == string("<=/=>")))); } } vector res, vis(n); for(auto g: dsu.group_up()){ if(vis[g[0] >> 1]){ continue; } for(auto u2: g){ vis[u2 >> 1] = true; } if(dsu.share(g[0], g[0] ^ 1)){ cout << "No\n"; return 0; } array cnt{}; for(auto u2: g){ ++ cnt[u2 & 1]; } int rem = cnt[0] < cnt[1]; for(auto u2: g){ if(u2 % 2 == rem){ res.push_back(u2 >> 1); } } } if((int)res.size() * 2 >= n){ sort(res.begin(), res.end()); cout << "Yes\n" << (int)res.size() << "\n"; for(auto u: res){ cout << u + 1 << " "; } cout << "\n"; } else{ cout << "No\n"; } return 0; } /* */ //////////////////////////////////////////////////////////////////////////////////////// // // // Coded by Aeren // // // ////////////////////////////////////////////////////////////////////////////////////////