#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
using namespace std;
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const int maxn = 2000 * 100 + 5;
const long long inf = 9223372036854775807;
const long long mod = 1e9 + 7;
const int lg = 20;
int n, m, h[2][maxn], cnt[2][2], can[2], res[2], mark[2][maxn], ans, N;
vector<int> adj[2][maxn], l[2], s[2];
void dfs(int id, int v, int p) {
  mark[id][v] = 1;
  if (v <= N) l[h[id][v] & 1].push_back(v);
  if (v <= N) cnt[id][h[id][v] & 1]++;
  for (auto u : adj[id][v]) {
    if (!mark[id][u]) {
      h[id][u] = h[id][v] + 1;
      dfs(id, u, v);
    } else if (u != p) {
      if (h[id][u] % 2 == h[id][v] % 2) {
        can[id] = 1;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  N = n;
  int u, v;
  char c;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v >> c;
    if (c == 'R') {
      adj[0][v].push_back(u);
      adj[0][u].push_back(v);
      adj[1][++n].push_back(v);
      adj[1][v].push_back(n);
      adj[1][n].push_back(u);
      adj[1][u].push_back(n);
    } else {
      adj[1][v].push_back(u);
      adj[1][u].push_back(v);
      adj[0][++n].push_back(v);
      adj[0][v].push_back(n);
      adj[0][n].push_back(u);
      adj[0][u].push_back(n);
    }
  }
  for (int i = 1; i <= N; i++) {
    if (!mark[0][i]) {
      h[0][i] = 1;
      cnt[0][1] = cnt[0][0] = 0;
      l[0].clear();
      l[1].clear();
      dfs(0, i, 0);
      res[0] += min(cnt[0][0], cnt[0][1]);
      if ((long long)(l[0]).size() == min(cnt[0][0], cnt[0][1])) {
        for (auto u : l[0]) s[0].push_back(u);
      } else {
        for (auto u : l[1]) s[0].push_back(u);
      }
    }
    if (!mark[1][i]) {
      h[1][i] = 1;
      cnt[1][1] = cnt[1][0] = 0;
      l[0].clear();
      l[1].clear();
      dfs(1, i, 0);
      res[1] += min(cnt[1][0], cnt[1][1]);
      if ((long long)(l[0]).size() == min(cnt[1][0], cnt[1][1])) {
        for (auto u : l[0]) s[1].push_back(u);
      } else {
        for (auto u : l[1]) s[1].push_back(u);
      }
    }
  }
  ans = mod;
  if (!can[0]) ans = min(ans, res[0]);
  if (!can[1]) ans = min(ans, res[1]);
  if (ans == res[0] && !can[0]) {
    cout << ans << endl;
    for (auto u : s[0]) cout << u << " ";
  } else if (ans == res[1] && !can[1]) {
    cout << ans << endl;
    for (auto u : s[1]) cout << u << " ";
  } else {
    cout << -1;
  }
}
