#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000 + 10;
const int maxn5 = 2 * 100 * 1000 + 10;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1LL * 2 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
vector<vector<int> > comp, ans[2][2];
bool mark[maxn5], ud[maxn5], clr, turn, re, best[2][maxn5];
vector<pair<int, bool> > adj[maxn5];
int cnum = 0;
void comp_dfs(int v) {
  mark[v] = true;
  comp.back().push_back(v);
  for (auto u : adj[v])
    if (!mark[u.first]) comp_dfs(u.first);
  return;
}
void dfs(int v, int par) {
  mark[v] = true;
  for (auto a : adj[v]) {
    int u = a.first;
    if (!mark[u]) {
      if ((ud[v] ? !(a.second) : a.second) != clr)
        ud[u] = true;
      else
        ud[u] = false;
      dfs(u, v);
    } else if (u != par and (ud[v] == ud[u] ? a.second : !(a.second)) != clr)
      re = false;
  }
  if (ud[v]) ans[clr == 0 ? 0 : 1][turn == 0 ? 0 : 1][cnum].push_back(v);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    char r;
    cin >> a >> b >> r;
    adj[a].push_back(make_pair(b, r == 'R' ? 1 : 0));
    adj[b].push_back(make_pair(a, r == 'R' ? 1 : 0));
  }
  for (int i = 1; i <= n; i++)
    if (!mark[i]) {
      vector<int> v, a;
      ans[0][0].push_back(a);
      ans[1][0].push_back(a);
      ans[0][1].push_back(a);
      ans[1][1].push_back(a);
      comp.push_back(v);
      comp_dfs(i);
    }
  fill(mark, mark + maxn5, false);
  long long cntr = 0, cntb = 0;
  cnum = 0;
  clr = 1;
  for (auto c : comp) {
    if (cntr == -1) break;
    int a = -1, b = -1;
    for (auto v : c)
      for (auto u : adj[v])
        if (!u.second) {
          a = v;
          b = u.first;
        }
    bool check;
    if (a == -1) continue;
    turn = 0;
    ud[a] = true;
    re = true;
    dfs(a, -1);
    for (auto u : c) mark[u] = false;
    check = re;
    turn = 1;
    ud[b] = true;
    re = true;
    dfs(b, -1);
    if (check and re) {
      cntr += min(ans[1][0][cnum].size(), ans[1][1][cnum].size());
      if (ans[1][0][cnum].size() > ans[1][1][cnum].size()) best[1][cnum] = true;
    } else if (check) {
      cntr += ans[1][0][cnum].size();
    } else if (re) {
      cntr += ans[1][1][cnum].size();
      best[1][cnum] = true;
    } else
      cntr = -1;
    cnum++;
  }
  fill(mark, mark + maxn5, false);
  cnum = 0;
  clr = 0;
  for (auto c : comp) {
    if (cntb == -1) break;
    int a = -1, b = -1;
    for (auto v : c)
      for (auto u : adj[v])
        if (u.second) {
          a = v;
          b = u.first;
        }
    bool check;
    if (a == -1) continue;
    turn = 0;
    ud[a] = true;
    re = true;
    dfs(a, -1);
    for (auto u : c) mark[u] = false;
    check = re;
    turn = 1;
    ud[b] = true;
    re = true;
    dfs(b, -1);
    if (check and re) {
      cntb += min(ans[0][0][cnum].size(), ans[0][1][cnum].size());
      if (ans[0][0][cnum].size() > ans[0][1][cnum].size()) best[0][cnum] = true;
    } else if (check) {
      cntb += ans[0][0][cnum].size();
    } else if (re) {
      cntb += ans[0][1][cnum].size();
      best[0][cnum] = true;
    } else
      cntb = -1;
    cnum++;
  }
  int c = 0;
  if (cntr != -1 and cntb != -1) {
    if (cntr < cntb) c = 1;
  } else if (cntr != -1)
    c = 1;
  else if (cntb != -1)
    c = 0;
  else
    return cout << -1 << endl, 0;
  cout << (c == 0 ? cntb : cntr) << endl;
  for (int i = 0; i < comp.size(); i++)
    for (auto u : ans[c][best[c][i]][i]) cout << u << ' ';
  cout << endl;
  return 0;
}
