#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > near[100010];
vector<int> s1, s2, sub;
vector<int> out;
int c[100010];
bool vis[100010];
bool f[2];
void dfs(int now, int d, int co) {
  if (vis[now]) {
    if (c[now] != d) f[co] = true;
    return;
  }
  c[now] = d;
  vis[now] = true;
  if (c[now])
    s1.push_back(now);
  else
    s2.push_back(now);
  for (auto x : near[now]) {
    int nxt = x.first, t = x.second;
    dfs(nxt, d ^ (t ^ co), co);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    char ch;
    cin >> u >> v >> ch;
    if (ch == 'B') {
      near[u].push_back(make_pair((v), (0)));
      near[v].push_back(make_pair((u), (0)));
    } else if (ch == 'R') {
      near[u].push_back(make_pair((v), (1)));
      near[v].push_back(make_pair((u), (1)));
    }
  }
  for (int i = 1; i <= n; i++) {
    s1.clear();
    s2.clear();
    if (!vis[i]) dfs(i, 0, 0);
    if (s1.size() < s2.size())
      copy(s1.begin(), s1.end(), back_inserter(sub));
    else
      copy(s2.begin(), s2.end(), back_inserter(sub));
  }
  out = sub;
  fill(vis, vis + n + 1, 0);
  sub.clear();
  for (int i = 1; i <= n; i++) {
    s1.clear();
    s2.clear();
    if (!vis[i]) dfs(i, 0, 1);
    if (s1.size() < s2.size())
      copy(s1.begin(), s1.end(), back_inserter(sub));
    else
      copy(s2.begin(), s2.end(), back_inserter(sub));
  }
  if ((out.size() > sub.size() || f[0]) && !f[1]) out = sub;
  if (f[0] && f[1])
    cout << -1 << endl;
  else {
    cout << out.size() << endl;
    for (int i = 0; i < out.size(); i++)
      cout << out[i] << (i == out.size() - 1 ? '\n' : ' ');
  }
  return 0;
}
