#include <bits/stdc++.h>
using namespace std;
int n, m, res;
vector<int> vec;
vector<pair<int, int> > adj[100005];
void solve(int flag) {
  vector<int> color(n + 5, -1);
  vector<int> memo[2];
  int freq[2] = {0, 0};
  function<bool(int, int)> dfs = [&](int u, int p) {
    freq[color[u]]++;
    memo[color[u]].push_back(u);
    for (pair<int, int> par : adj[u]) {
      int v = par.first, w = par.second;
      if (v == p) continue;
      int c = (w == flag ? color[u] : !color[u]);
      if (color[v] == -1) {
        color[v] = c;
        if (!dfs(v, u)) return false;
      } else if (color[v] != c)
        return false;
    }
    return true;
  };
  int sum = 0;
  vector<int> aux;
  for (int i = 1; i <= n; i++)
    if (color[i] == -1) {
      freq[0] = freq[1] = 0;
      memo[0].clear();
      memo[1].clear();
      color[i] = 0;
      if (!dfs(i, -1)) return;
      sum += min(freq[0], freq[1]);
      if (freq[0] < freq[1])
        aux.insert(aux.end(), memo[0].begin(), memo[0].end());
      else
        aux.insert(aux.end(), memo[1].begin(), memo[1].end());
    }
  if (sum < res) {
    res = sum;
    vec = aux;
  }
}
int main() {
  cout.sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    adj[u].emplace_back(v, (c == 'R'));
    adj[v].emplace_back(u, (c == 'R'));
  }
  res = 1e9;
  solve(0);
  solve(1);
  if (res == 1e9) res = -1;
  cout << res << endl;
  for (int val : vec) cout << val << " ";
  cout << endl;
  return 0;
}
