#ifndef DEBUG #pragma GCC target("avx2") #pragma GCC optimize("Ofast,unroll-loops") #endif #include #include #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(a) a.begin(), a.end() #define ll long long using namespace std; using namespace atcoder; void solve() { int n, m; cin >> n >> m; dsu d(2 * n); vector> g(2 * n); rep(qqq, m) { int i, j; string s; cin >> i >> s >> j; i--, j--; if (s.length() == 4) { d.merge(i, j); d.merge(i + n, j + n); g[i].push_back(j); g[j].push_back(i); g[i + n].push_back(j + n); g[j + n].push_back(i + n); } else { d.merge(i, j + n); d.merge(i + n, j); g[i].push_back(j + n); g[j + n].push_back(i); g[j].push_back(i + n); g[i + n].push_back(j); } } rep(i, n) { if (d.same(i, i + n)) { cout << "No" << '\n'; return; } } vector ans; vector used(n); queue q; rep(st, n) { if (used[st]) continue; ans.push_back(st); used[st] = true; q.push(st); while (!q.empty()) { const int x = q.front(); q.pop(); for (int i : g[x]) { if (used[i % n]) continue; if (i < n) ans.push_back(i); used[i % n] = true; q.push(i); } } } if (ans.size() * 2 < n) { cout << "No" << '\n'; return; } sort(ALL(ans)); int size = ans.size(); cout << "Yes" << '\n'; cout << size << '\n'; rep(i, size) cout << ans[i] + 1 << " \n"[i + 1 == size]; } int main() { // srand((unsigned)time(NULL)); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(40); solve(); return 0; }