#include <bits/stdc++.h>
using namespace std;
const int maxn = int(1e5) + 100;
const int oo = int(1e8);
struct LINK {
  int id, next, type;
};
int n, m;
int now;
int ans1, ans2;
int choose;
int tail;
int q[maxn];
int h[maxn];
bool done[maxn], vis[maxn];
bool rev[maxn];
LINK t[maxn * 2];
int getnum() {
  char ch;
  while ((ch = getchar()) != 'R' && ch != 'B')
    ;
  return (ch == 'R');
}
void join(int u, int v, int ty) {
  t[now].id = v;
  t[now].next = h[u];
  t[now].type = ty;
  h[u] = now++;
  t[now].id = u;
  t[now].next = h[v];
  t[now].type = ty;
  h[v] = now++;
}
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) h[i] = -1;
  for (int i = 1; i <= m; ++i) {
    int u, v, type;
    scanf("%d%d", &u, &v);
    type = getnum();
    join(u, v, type);
  }
}
void bfs(int st) {
  int head = 1;
  tail = 1;
  q[1] = st;
  done[st] = true;
  while (head <= tail) {
    int cur = q[head++];
    for (int i = h[cur]; i > -1; i = t[i].next)
      if (!done[t[i].id]) {
        q[++tail] = t[i].id;
        done[t[i].id] = true;
      }
  }
}
int calc(int c) {
  rev[q[1]] = c;
  for (int i = 1; i <= tail; ++i) vis[q[i]] = false;
  vis[q[1]] = true;
  for (int i = 1; i <= tail; ++i) {
    int cur = q[i];
    for (int j = h[cur]; j > -1; j = t[j].next) {
      if (vis[t[j].id] && ((t[j].type ^ rev[cur] ^ rev[t[j].id]) != choose))
        return oo;
      if (vis[t[j].id]) continue;
      rev[t[j].id] = t[j].type ^ rev[cur] ^ choose;
      vis[t[j].id] = true;
    }
  }
  int s = 0;
  for (int i = 1; i <= tail; ++i) s += rev[q[i]];
  return s;
}
int doit() {
  int ans = 0;
  for (int i = 1; i <= n; ++i) done[i] = false;
  for (int i = 1; i <= n; ++i)
    if (!done[i]) {
      bfs(i);
      int tmp = min(calc(0), calc(1));
      if (tmp == oo) return oo;
      ans += tmp;
    }
  return ans;
}
void print() {
  for (int i = 1; i <= n; ++i) done[i] = false;
  for (int i = 1; i <= n; ++i)
    if (!done[i]) {
      bfs(i);
      int tmp = calc(0);
      if (calc(1) > tmp) calc(0);
    }
  for (int i = 1; i <= n; ++i)
    if (rev[i]) printf("%d ", i);
  printf("\n");
}
void solve() {
  choose = 1;
  ans1 = doit();
  choose = 0;
  ans2 = doit();
  if (ans1 <= ans2) choose = 1;
  if (min(ans1, ans2) == oo) {
    printf("-1\n");
    return;
  }
  if (choose == 1)
    printf("%d\n", ans1);
  else
    printf("%d\n", ans2);
  print();
}
int main() {
  init();
  solve();
  return 0;
}
