func_code_string: #include <bits/stdc++.h>   using namespace std;   pair<pair<int, int>, int> e[100010];   int parent[100010];   int Rank[100010];   int sz[100010];   vector<int> v[100010];   bool mark[100010];   bool mark1[100010];   int color[100010];   vector<int> out[2];   bool success[2];   int cnt[2];   int n, m;   int find(int cur) {     if (parent[cur] == cur) return cur;     return parent[cur] = find(parent[cur]);   }   void Union(int x, int y) {     int xroot = find(x);     int yroot = find(y);     if (xroot == yroot) return;     if (Rank[xroot] < Rank[yroot])       parent[xroot] = yroot;     else if (Rank[xroot] > Rank[yroot])       parent[yroot] = xroot;     else {       Rank[xroot]++;       parent[yroot] = xroot;     }   }   void init(int n) {     int i;     for (i = 0; i <= n; ++i) {       Rank[i] = 0;       parent[i] = i;       sz[i] = 0;     }   }   bool dfs(int cur, int c) {     mark[cur] = 1;     color[cur] = c;     cnt[c] += sz[cur];     for (int i = 0; i < v[cur].size(); ++i) {       if (mark[v[cur][i]]) {         if (color[v[cur][i]] == c) return 0;         continue;       }       if (!dfs(v[cur][i], 1 - c)) return 0;     }     return 1;   }   void dfs1(int cur) {     mark1[cur] = 1;     color[cur] = 1 - color[cur];     for (int i = 0; i < v[cur].size(); ++i)       if (!mark1[v[cur][i]]) dfs1(v[cur][i]);   }   void solve(int f) {     int i;     init(n);     success[f] = 0;     for (i = 1; i <= n; ++i) v[i].clear();     for (i = 0; i < m; ++i)       if (e[i].second == f) Union(e[i].first.first, e[i].first.second);     for (i = 0; i < m; ++i)       if (e[i].second != f) {         int x = find(e[i].first.first), y = find(e[i].first.second);         if (x == y) return;         v[x].push_back(y);         v[y].push_back(x);       }     for (i = 1; i <= n; ++i) sz[find(i)]++;     memset(mark, 0, sizeof(mark));     memset(mark1, 0, sizeof(mark1));     for (i = 1; i <= n; ++i) {       cnt[0] = cnt[1] = 0;       if (mark[find(i)]) continue;       if (!dfs(find(i), 0)) return;       if (cnt[0] > cnt[1]) dfs1(find(i));     }     success[f] = 1;     for (i = 1; i <= n; ++i)       if (color[find(i)] == 0) out[f].push_back(i);   }   int main() {     int i, x, y, c;     string s;     scanf( %d , &n);     scanf( %d , &m);     for (i = 0; i < m; ++i) {       scanf( %d , &x);       scanf( %d , &y);       cin >> s;       if (s[0] ==  R )         c = 0;       else         c = 1;       e[i] = make_pair(make_pair(x, y), c);     }     solve(0);     solve(1);     int minn = 1000000, minpos;     for (i = 0; i < 2; ++i)       if (success[i])         if ((int)out[i].size() < minn) {           minn = (int)out[i].size();           minpos = i;         }     if (minn == 1000000)       printf( %d n , -1);     else {       printf( %d n , minn);       for (auto it : out[minpos]) printf( %d  , it);       printf(  n );     }   }   