#include #include #include using namespace std; #include using namespace atcoder; int main() { int N; cin >> N; using P = pair; std::vector

Eq, Neq; int M; cin >> M; while (M--) { int a, b; string s; cin >> a >> s >> b; if (s == "<==>") { Eq.emplace_back(--a, --b); } else { Neq.emplace_back(--a, --b); } } dsu D(N); for (auto [a, b] : Eq) { D.merge(a, b); } auto grp = D.groups(); vector ID(N); for (int i = 0; i < grp.size(); i++) { for (auto v : grp[i]) { ID[v] = i; } } vector gr[200020]; for (auto [u, v] : Neq) { u = ID[u]; v = ID[v]; gr[u].push_back(v); gr[v].push_back(u); } vector did(N, -1); vector ans; for (int i = 0; i < N; i++) { if (did[i] != -1) { continue; } did[i] = 0; vector X[2]; for (auto v : grp[i]) { X[0].push_back(v); } stack st; st.push(0); bool ok = true; while (!st.empty()) { int u = st.top(); st.pop(); for (auto v : gr[u]) { if (did[v] == did[u]) { ok = false; break; } if (did[v] == -1) { did[v] = did[u] ^ 1; st.push(v); for (auto x : grp[v]) { X[did[v]].push_back(x); } } } } if (!ok) { puts("No : NG formula"); return 0; } // for (int x = 0; x < 2; x++) { // printf("%d : ", x); // for (auto a : X[x]) { // cout << a << " "; // } // cout << endl; // } auto& vc = (X[0].size() > X[1].size() ? X[0] : X[1]); for (auto v : vc) { ans.push_back(v + 1); } } // for (auto a : ans) { // cout << a << " "; // } // cout << endl; if (ans.size() * 2 < N) { puts("No"); return 0; } else { puts("Yes"); cout << ans.size() << endl; sort(ans.begin(), ans.end()); for (auto a : ans) { cout << a << (a == ans.back() ? "" : " "); } cout << endl; } }