#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > s[1 << 20];
int can[2];
vector<int> ans[2];
int dp[1 << 20];
int us[1 << 20];
int main(void) {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b;
    char ch;
    int ok;
    cin >> a >> b >> ch;
    ok = ch == 'R' ? 1 : 0;
    s[a].push_back({b, ok});
    s[b].push_back({a, ok});
  }
  can[0] = can[1] = 1;
  for (int C = 0; C < 2; ++C) {
    for (int i = 1; i <= n; ++i) us[i] = 0;
    for (int i = 1; i <= n; ++i)
      if (!us[i]) {
        vector<int> v;
        queue<int> q;
        q.push(i);
        v.push_back(i);
        us[i] = 1;
        dp[i] = 0;
        while (!q.empty()) {
          int node = q.front();
          q.pop();
          for (auto it : s[node])
            if (!us[it.first]) {
              q.push(it.first);
              v.push_back(it.first);
              us[it.first] = 1;
              dp[it.first] = C ^ it.second ^ dp[node];
            }
        }
        for (auto vertex : v)
          for (auto it : s[vertex])
            if (dp[it.first] != (C ^ it.second ^ dp[vertex])) can[C] = 0;
        int cnt = 0;
        for (auto vertex : v) cnt += !dp[vertex];
        int how = (cnt < v.size() - cnt) ? 0 : 1;
        for (auto vertex : v)
          if (dp[vertex] == how) ans[C].push_back(vertex);
      }
  }
  if (!can[0] && !can[1]) return puts("-1") * 0;
  int who = 0;
  if (!can[0])
    who = 1;
  else if (!can[1])
    who = 0;
  else if (ans[0].size() < ans[1].size())
    who = 0;
  else
    who = 1;
  cout << (ans[who].size()) << '\n';
  for (auto it : ans[who]) cout << it << ' ';
  cout << '\n';
  return 0;
}
