#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 100;
vector<pair<int, int> > E[MAXN];
int flipped[MAXN];
int seen[MAXN];
int n;
int cc[MAXN];
vector<int> in_component[MAXN];
int component[MAXN];
bool global_seen[MAXN];
void dfs(int u, int cc) {
  global_seen[u] = 1;
  component[u] = cc;
  in_component[cc].push_back(u);
  for (pair<int, int> e : E[u]) {
    int to = e.first;
    if (global_seen[to]) continue;
    dfs(to, cc);
  }
}
vector<int> inf;
vector<int> bfs(int u, int target_color, int flip_first) {
  int cc = component[u];
  for (int nodo : in_component[cc]) {
    seen[nodo] = 0;
    flipped[nodo] = 0;
  }
  flipped[u] = flip_first;
  queue<int> Q;
  Q.push(u);
  seen[u] = 1;
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    for (pair<int, int> E : E[v]) {
      int current_color = E.second;
      int to = E.first;
      int actual_color = flipped[v] ^ current_color;
      if (seen[to]) {
        if (flipped[to] && actual_color == target_color) return inf;
        if (actual_color != target_color && !flipped[to]) return inf;
      } else {
        seen[to] = 1;
        if (actual_color != target_color) {
          flipped[to] = 1;
        }
        Q.push(to);
      }
    }
  }
  vector<int> ans;
  for (int nodo : in_component[cc]) {
    if (flipped[nodo]) ans.push_back(nodo);
  }
  return ans;
}
vector<int> changes[MAXN][2];
int opt[MAXN];
int main() {
  int m;
  cin >> n >> m;
  for (int i = 1; i <= n + 5; i++) inf.push_back(i);
  for (int i = 0; i < m; i++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    int color = (c == 'R') ? 1 : 0;
    E[u].push_back(make_pair(v, color));
    E[v].push_back(make_pair(u, color));
  }
  int ans = n + 2;
  vector<int> best;
  vector<int> roots;
  int compos = 0;
  for (int i = 1; i <= n; i++) {
    if (global_seen[i]) continue;
    roots.push_back(i);
    dfs(i, compos++);
  }
  for (int i = 1; i <= n; i++) global_seen[i] = 0;
  int best_k = -1;
  for (int k = 0; k < 2; k++) {
    int cur = 0;
    for (int i : roots) {
      int best_comp = n + 5;
      for (int j = 0; j < 2; j++) {
        vector<int> a = bfs(i, k, j);
        int cur_sz = a.size();
        if (best_comp > cur_sz) {
          best_comp = cur_sz;
          changes[i][k] = a;
        }
      }
      cur += best_comp;
    }
    if (ans > cur) {
      ans = cur;
      best_k = k;
    }
  }
  if (ans > n) {
    puts("-1");
    return 0;
  }
  vector<int> best_c;
  for (int r : roots) {
    for (int v : changes[r][best_k]) best_c.push_back(v);
  }
  cout << best_c.size() << endl;
  for (int u : best_c) {
    cout << u << " ";
  }
  cout << endl;
  return 0;
}
