func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool getmin(T *a, const T &b) {     if (b < *a) {       *a = b;       return true;     }     return false;   }   template <class T>   inline bool getmax(T *a, const T &b) {     if (b > *a) {       *a = b;       return true;     }     return false;   }   template <class T>   inline void read(T *a) {     char c;     while (isspace(c = getchar())) {     }     bool flag = 0;     if (c ==  - )       flag = 1, *a = 0;     else       *a = c - 48;     while (isdigit(c = getchar())) *a = *a * 10 + c - 48;     if (flag) *a = -*a;   }   const int mo = 1000000007;   template <class T>   T pow(T a, T b, int c = mo) {     T res = 1;     for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c)       if (b & i) res = 1LL * res * a % c;     return res;   }   const int inf = 1000000000;   const int N = 210000;   struct node {     int p, nextt, w;   } edge[N];   int cnt;   int head[N];   void ae(int a, int b, int c) {     edge[++cnt].p = b;     edge[cnt].nextt = head[a];     edge[cnt].w = c;     head[a] = cnt;   }   queue<int> q;   int d[N], tmp[N];   int n, m;   int bfs(int u) {     static vector<int> v;     v.clear();     d[u] = 0;     while (!q.empty()) q.pop();     q.push(u);     int ans = 0, num = 0;     while (!q.empty()) {       int u = q.front();       q.pop();       ans += d[u];       v.push_back(u);       ++num;       for (int k = head[(u)]; k; k = edge[k].nextt) {         int v = edge[k].p;         if (d[v] != -1 && (d[u] ^ d[v]) != edge[k].w)           return inf;         else if (d[v] == -1) {           d[v] = (d[u] ^ edge[k].w);           q.push(v);         }       }     }     for (int i = (0); i <= (num - 1); ++i)       if (num - ans < ans) d[v[i]] ^= 1;     return min(ans, num - ans);   }   int solve() {     for (int i = (1); i <= (n); ++i) d[i] = -1;     int ans = 0;     for (int i = (1); i <= (n); ++i)       if (d[i] == -1) {         int x = bfs(i);         if (x == inf)           return inf;         else           ans += x;       }     return ans;   }   int main() {     cin >> n >> m;     for (int i = (1); i <= (m); ++i) {       int x, y;       string s;       cin >> x >> y >> s;       int z = 0;       if (s ==  R ) z = 1;       ae(x, y, z);       ae(y, x, z);     }     int ans = solve();     for (int i = (1); i <= (n); ++i) tmp[i] = d[i];     for (int i = (1); i <= (n); ++i)       for (int k = head[(i)]; k; k = edge[k].nextt) edge[k].w ^= 1;     int x = solve();     if (x < ans) {       ans = x;       for (int i = (1); i <= (n); ++i) tmp[i] = d[i];     }     if (ans == inf) {       cout << -1 << endl;     } else {       cout << ans << endl;       for (int i = (1); i <= (n); ++i)         if (tmp[i]) printf( %d  , i);       cout << endl;     }     return 0;   }   