#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 1100, OO = 1e12 + 7, M = 1e9 + 7, P = 6151, sq = 500,
                lg = 23;
bool c[N], mark[N], t = true, tp[N];
vector<pair<long long, bool> > v[N];
vector<long long> s0, s1, f;
long long ans = OO, b = 0, b0 = true, b1 = true;
void dfs(long long x) {
  tp[x] = true;
  if (c[x]) b++, f.push_back(x);
  mark[x] = true;
  for (auto ufc : v[x]) {
    long long u = ufc.first, is = ufc.second;
    if (mark[u]) {
      if (c[u] == c[x] && is != t) {
        b = OO;
        return;
      }
      if (c[u] != c[x] && is == t) {
        b = OO;
        return;
      }
    } else {
      if (is == t)
        c[u] = c[x];
      else
        c[u] = c[x] ^ 1;
      dfs(u);
    }
  }
}
void cle(long long x) {
  mark[x] = 0;
  c[x] = 0;
  for (auto u : v[x])
    if (mark[u.first]) cle(u.first);
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    char ch;
    cin >> x >> y >> ch;
    v[x].push_back({y, (ch == 'R')});
    v[y].push_back({x, (ch == 'R')});
  }
  vector<long long> h0, h1;
  for (long long i = 1; i <= n; i++) {
    if (tp[i]) continue;
    if (b0 == true) {
      t = true;
      ans = OO;
      c[i] = true;
      b = 0;
      dfs(i);
      ans = min(ans, b);
      if (ans == b) s0 = f;
      cle(i);
      f.clear();
      b = 0;
      dfs(i);
      ans = min(ans, b);
      if (ans == b) s0 = f;
      if (ans == OO) b0 = false;
      cle(i);
      f.clear();
      for (auto u : s0) h0.push_back(u);
    }
    if (b1 == true) {
      ans = OO;
      t = false;
      c[i] = true;
      b = 0;
      dfs(i);
      ans = min(ans, b);
      if (ans == b) s1 = f;
      cle(i);
      f.clear();
      b = 0;
      dfs(i);
      ans = min(ans, b);
      if (ans == b) s1 = f;
      if (ans == OO) b1 = false;
      cle(i);
      f.clear();
      for (auto u : s1) h1.push_back(u);
    }
  }
  vector<long long> h;
  if (b0 == false && b1 == false) return cout << -1, 0;
  if (b0 == false)
    h = h1;
  else if (b1 == false)
    h = h0;
  else if (h0.size() < h1.size())
    h = h0;
  else
    h = h1;
  cout << h.size() << endl;
  for (auto u : h) cout << u << " ";
  return 0;
}
