#include <bits/stdc++.h>
using namespace std;
template <typename T>
T read1() {
  T t = 0;
  char k;
  bool vis = 1;
  do (k = getchar()) == '-' && (vis = 0);
  while ('0' > k || k > '9');
  while ('0' <= k && k <= '9')
    t = (t << 3) + (t << 1) + (k ^ '0'), k = getchar();
  return vis ? t : -t;
}
int n, m, ty[100001], ty1[100001];
vector<int> G[100001];
vector<bool> V[100001];
stack<int> sta;
int dfs(int n, int x, int *y) {
  int t = y[n] & 1;
  sta.push(n);
  for (int i = 0; i < G[n].size(); ++i)
    if (!y[G[n][i]]) {
      y[G[n][i]] = y[n] ^ x ^ V[n][i];
      int o = dfs(G[n][i], x, y);
      if (!~o) return -1;
      t += o;
    } else if (y[G[n][i]] != y[n] ^ x ^ V[n][i])
      return -1;
  return t;
}
int main() {
  n = read1<long long>(), m = read1<long long>();
  for (int i = 1; i <= m; ++i) {
    int u = read1<long long>(), v = read1<long long>();
    char k;
    cin >> k;
    G[u].push_back(v);
    G[v].push_back(u);
    V[u].push_back(k == 'R');
    V[v].push_back(k == 'R');
  }
  int t = 0, t1 = 0;
  for (int i = 1; i <= n; ++i)
    if (!ty[i]) {
      ty[i] = 2;
      int x = dfs(i, 0, ty);
      while (!sta.empty()) ty[sta.top()] = 0, sta.pop();
      if (!~x) {
        t = -1;
        break;
      }
      ty[i] = 3;
      int y = dfs(i, 0, ty);
      while (!sta.empty()) sta.pop();
      if (x < y)
        ty[i] = -2, t += x;
      else
        ty[i] = -3, t += y;
    }
  for (int i = 1; i <= n; ++i)
    if (!ty1[i]) {
      ty1[i] = 2;
      int x = dfs(i, 1, ty1);
      while (!sta.empty()) ty1[sta.top()] = 0, sta.pop();
      if (!~x) {
        t1 = -1;
        break;
      }
      ty1[i] = 3;
      int y = dfs(i, 1, ty1);
      while (!sta.empty()) sta.pop();
      if (x < y)
        ty1[i] = -2, t1 += x;
      else
        ty1[i] = -3, t1 += y;
    }
  if (!~t && !~t1) return puts("-1"), 0;
  if (!~t) t = 1e9;
  if (!~t1) t1 = 1e9;
  if (t < t1) {
    printf("%d\n", t);
    for (int i = n; i; --i)
      if (ty[i] < 0)
        ty[i] = -ty[i], dfs(i, 0, ty);
      else
        ty[i] = 0;
    while (!sta.empty())
      (ty[sta.top()] & 1) && printf("%d ", sta.top()), sta.pop();
  } else {
    printf("%d\n", t1);
    for (int i = n; i; --i)
      if (ty1[i] < 0)
        ty1[i] = -ty1[i], dfs(i, 1, ty1);
      else
        ty1[i] = 0;
    while (!sta.empty())
      (ty1[sta.top()] & 1) && printf("%d ", sta.top()), sta.pop();
  }
  return 0;
}
