#include <bits/stdc++.h>
using namespace ::std;
struct TwoSat {
  int n, gn, check_num;
  vector<int> check;
  vector<int> order;
  vector<vector<int> > graph;
  vector<vector<int> > rev_graph;
  void init(int n1) {
    n = n1, gn = n1 << 1;
    graph.clear(), rev_graph.clear();
    graph.resize(gn), rev_graph.resize(gn);
    check_num = 0;
    check.resize(gn, 0);
  }
  int negation(int v) { return v < n ? v + n : v - n; }
  void add_edge(int v1, int v2) {
    graph[v1].push_back(v2);
    rev_graph[v2].push_back(v1);
  }
  void add_or(int v1, int v2) {
    add_edge(negation(v1), v2);
    add_edge(negation(v2), v1);
  }
  void dfs(int now, vector<vector<int> >& ad) {
    check[now] = check_num;
    for (int i = 0; i < ad[now].size(); i++) {
      int next = ad[now][i];
      if (check[next] != check_num) {
        dfs(next, ad);
      }
    }
    order.push_back(now);
  }
  vector<bool> result() {
    int scc_num = 0;
    vector<bool> ret(n);
    vector<int> scc(gn);
    check_num++;
    order.clear();
    for (int i = 0; i < gn; i++)
      if (check[i] != check_num) dfs(i, graph);
    check_num++;
    vector<int> re_order = vector<int>(order.rbegin(), order.rend());
    for (int i = 0; i < re_order.size(); i++) {
      int now = re_order[i];
      if (check[now] == check_num) continue;
      scc_num++;
      order.clear();
      dfs(now, rev_graph);
      for (int j = 0; j < order.size(); j++) {
        scc[order[j]] = scc_num;
        if (scc[negation(order[j])] == scc_num) {
          ret.clear();
          return ret;
        }
        ret[order[j] < n ? order[j] : order[j] - n] = (order[j] < n);
      }
    }
    return ret;
  }
} ts_red, ts_blue, ts_red1, ts_blue1;
const int N = 100000;
int n, m;
int cnt[N + 5];
vector<int> ad[N + 5];
vector<bool> c[N + 5];
bool chk[N + 5];
vector<int> p;
int num[N + 5], num_r[N + 5];
void go_dfs(int now) {
  chk[now] = true;
  p.push_back(now);
  for (auto next : ad[now])
    if (!chk[next]) go_dfs(next);
}
int main() {
  scanf("%d %d", &n, &m);
  ts_red.init(n);
  ts_blue.init(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    char color;
    scanf("%d %d %c", &v1, &v2, &color);
    ad[v1].push_back(v2);
    ad[v2].push_back(v1);
    c[v1].push_back(color == 'B');
    c[v2].push_back(color == 'B');
  }
  bool red = true, blue = true;
  vector<int> l1, l2;
  for (int i = 1; i <= n; i++) {
    if (!chk[i]) {
      p.clear();
      go_dfs(i);
      for (int j = 0; j < p.size(); j++) {
        num[p[j]] = j;
        num_r[j] = p[j];
      }
      ts_red.init(p.size());
      ts_blue.init(p.size());
      for (auto w1 : p) {
        for (int j = 0; j < ad[w1].size(); j++) {
          int w2 = ad[w1][j];
          int v1 = num[w1];
          int v2 = num[w2];
          if (c[w1][j]) {
            ts_red.add_or(v1, v2);
            ts_red.add_or(ts_red.negation(v1), ts_red.negation(v2));
            ts_blue.add_or(v1, ts_blue.negation(v2));
            ts_blue.add_or(ts_blue.negation(v1), v2);
          } else {
            ts_red.add_or(v1, ts_red.negation(v2));
            ts_red.add_or(ts_red.negation(v1), v2);
            ts_blue.add_or(v1, v2);
            ts_blue.add_or(ts_blue.negation(v1), ts_blue.negation(v2));
          }
        }
      }
      ts_red1 = ts_red;
      ts_blue1 = ts_blue;
      ts_red.add_or(0, 0);
      ts_blue.add_or(0, 0);
      ts_red1.add_or(ts_red.negation(0), ts_red.negation(0));
      ts_blue1.add_or(ts_red.negation(0), ts_red.negation(0));
      vector<bool> ans1 = ts_red.result(), ans2 = ts_red1.result();
      red &= (ans1.size() != 0 || ans2.size() != 0);
      int c1 = 0, c2 = 0;
      for (auto b : ans1)
        if (b) c1++;
      for (auto b : ans2)
        if (b) c2++;
      if (ans1.size() == 0 || (ans2.size() != 0 && c1 > c2)) ans1 = ans2;
      for (int j = 0; j < ans1.size(); j++)
        if (ans1[j]) l1.push_back(num_r[j]);
      ans1 = ts_blue.result(), ans2 = ts_blue1.result();
      blue &= (ans1.size() != 0 || ans2.size() != 0);
      c1 = 0, c2 = 0;
      for (auto b : ans1)
        if (b) c1++;
      for (auto b : ans2)
        if (b) c2++;
      if (ans1.size() == 0 || (ans2.size() != 0 && c1 > c2)) ans1 = ans2;
      for (int j = 0; j < ans1.size(); j++)
        if (ans1[j]) l2.push_back(num_r[j]);
    }
  }
  if (!red && !blue)
    printf("-1");
  else {
    if (!red || (blue && l1.size() > l2.size())) l1 = l2;
    printf("%d\n", l1.size());
    for (auto i : l1) printf("%d ", i);
  }
  return 0;
}
