#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using ii = pair<int, int>;
using ll = pair<lint, lint>;
using ti = tuple<int, int, int>;
namespace T {
const int MAX = 1e5 + 5;
const int INF = 1e9 + 7;
int max_t[4 * MAX];
int min_t[4 * MAX];
void max_up(int n, int s, int e, int p, int v) {
  if (p < s || p > e) return;
  if (s == e)
    max_t[n] = v;
  else {
    max_up(2 * n, s, (s + e) / 2, p, v);
    max_up(2 * n + 1, (s + e) / 2 + 1, e, p, v);
    max_t[n] = max(max_t[2 * n], max_t[2 * n + 1]);
  }
}
void min_up(int n, int s, int e, int p, int v) {
  if (p < s || p > e) return;
  if (s == e)
    min_t[n] = v;
  else {
    min_up(2 * n, s, (s + e) / 2, p, v);
    min_up(2 * n + 1, (s + e) / 2 + 1, e, p, v);
    min_t[n] = min(min_t[2 * n], min_t[2 * n + 1]);
  }
}
int max_v(int n, int s, int e, int l, int r) {
  if (r < s || l > e) return 0;
  if (l <= s && e <= r) return max_t[n];
  int m = (s + e) / 2;
  return max(max_v(2 * n, s, m, l, r), max_v(2 * n + 1, m + 1, e, l, r));
}
int min_v(int n, int s, int e, int l, int r) {
  if (r < s || l > e) return INF;
  if (l <= s && e <= r) return min_t[n];
  int m = (s + e) / 2;
  return min(min_v(2 * n, s, m, l, r), min_v(2 * n + 1, m + 1, e, l, r));
}
}  // namespace T
namespace P {
const int N = 2 * 1e6 + 5;
using lint = long long;
bool v[N];
void make() {
  fill(v, v + N, true);
  for (int i = 2; i < N; i++) {
    if (v[i]) {
      for (lint j = (lint)i * i; j < N; j += i) {
        v[j] = false;
      }
    }
  }
}
}  // namespace P
namespace U {
int min3(int a, int b, int c) { return min(min(a, b), c); }
int min4(int a, int b, int c, int d) { return min(min(a, b), min(c, d)); }
}  // namespace U
const int N = 1e5 + 5;
const int inf = 1e9 + 5;
int n, m;
vector<ii> a[N];
void input() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    char s[2];
    scanf("%s", s);
    if (s[0] == 'B') {
      a[x].push_back(ii(y, 0));
      a[y].push_back(ii(x, 0));
    } else {
      a[x].push_back(ii(y, 1));
      a[y].push_back(ii(x, 1));
    }
  }
}
vector<int> v[2];
vector<int> component;
bool vis[N];
bool small_vis[N];
int cnt[4];
vector<int> nodes[4];
int colored[N];
int mp[N];
bool go(int now_idx, bool edges_col) {
  small_vis[now_idx] = true;
  int now = component[now_idx];
  for (auto p : a[now]) {
    int next = p.first;
    int next_idx = mp[next];
    int edge_col = p.second;
    if (!small_vis[next_idx]) {
      if ((colored[now_idx] + colored[next_idx] + edge_col) % 2 !=
          (edges_col)) {
        colored[next_idx] = 1;
      }
      if (!go(next_idx, edges_col)) {
        return false;
      }
    } else {
      if ((colored[now_idx] + colored[next_idx] + edge_col) % 2 !=
          (edges_col)) {
        return false;
      }
    }
  }
  return true;
}
void collect(int now) {
  vis[now] = true;
  mp[now] = component.size();
  component.push_back(now);
  for (auto p : a[now]) {
    int next = p.first;
    if (!vis[next]) {
      collect(next);
    }
  }
}
bool can_blue = true;
bool can_red = true;
vector<int> v4c[2];
void get(int st) {
  component.clear();
  collect(st);
  for (int i = 0; i < 4; i++) {
    cnt[i] = inf;
    nodes[i].clear();
  }
  const size_t sz = component.size();
  for (int i = 0; i < 4; i++) {
    fill(small_vis, small_vis + sz, false);
    fill(colored, colored + sz, 0);
    colored[0] = i & 1;
    if (go(0, i / 2)) {
      cnt[i] = 0;
      for (size_t j = 0; j < sz; j++) {
        if (colored[j]) {
          cnt[i]++;
          nodes[i].push_back(component[j]);
        }
      }
    }
  }
  if (cnt[1] < cnt[0]) {
    nodes[0] = nodes[1];
    cnt[0] = cnt[1];
  }
  if (cnt[3] < cnt[2]) {
    nodes[2] = nodes[3];
    cnt[2] = cnt[3];
  }
  if (cnt[0] == inf) {
    can_red = false;
  } else {
    for (int e : nodes[0]) {
      v4c[0].push_back(e);
    }
  }
  if (cnt[2] == inf) {
    can_blue = false;
  } else {
    for (int e : nodes[2]) {
      v4c[1].push_back(e);
    }
  }
}
void solve() {
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      get(i);
    }
  }
  vector<int> v;
  bool o = true;
  if (can_red) {
    if (can_blue) {
      if (v4c[0].size() > v4c[1].size()) {
        v = v4c[1];
      } else {
        v = v4c[0];
      }
    } else {
      v = v4c[0];
    }
  } else {
    if (can_blue) {
      v = v4c[1];
    } else {
      o = false;
      puts("-1");
    }
  }
  if (o) {
    printf("%d\n", (int)v.size());
    for (int e : v) {
      printf("%d ", e);
    }
  }
}
int main() {
  input();
  solve();
  return 0;
}
