#include using namespace std; #include using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair; using lb = long double; using T = tuple; #ifdef LOCAL # include # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast(0)) #endif int main() { int n, m; cin >> n >> m; dsu uf(n); vector> g(n); vector> e; rep(i,m){ int a, b; string s; cin >> a >> s >> b; --a;--b; if(s=="<==>"){ uf.merge(a,b); } else{ e.emplace_back(a,b); } } dbg(uf.groups()); for(auto [d,f] : e){ if(uf.same(d,f)){ cout << "No" << endl; return 0; } g[uf.leader(d)].push_back(uf.leader(f)); g[uf.leader(f)].push_back(uf.leader(d)); } dbg(g); //二部グラフ判定 vector color(n, -1); auto dfs = [&](auto dfs, int u, int c) -> bool { color[u] = c; for(int v : g[u]){ if(color[v] == c) return false; if(color[v]==-1 && !dfs(dfs,v, c^1)) return false; } return true; }; vector vis(n); vector> cnt(2); auto dfs2 = [&](auto dfs2, int u) -> void { vis[u] = true; cnt[color[u]].push_back(u); for(int v : g[u]){ if(!vis[v]) dfs2(dfs2,v); } }; int ans = 0; set t; rep(i,n){ if(color[i]==-1 && uf.leader(i)==i){ if(!dfs(dfs, i,0)){ cout<<"No" << endl; return 0; } cnt.clear(); dfs2(dfs2,i); int sum0, sum1 = 0; for(int c : cnt[0]) sum0 += uf.size(c); for(int c : cnt[1]) sum1 += uf.size(c); if(sum0>=sum1) { for(int c : cnt[0]) { t.insert(c); } } else{ for(int c : cnt[1]) t.insert(c); } ans += max(sum0,sum1); } } if(ans>=(n+1)/2){ cout << "Yes" << endl; cout << ans << endl; rep(i,n){ if(t.count(uf.leader(i))) cout << i + 1 << " "; } cout << endl; return 0; } cout << "No" << endl; return 0; }