#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& num) {
  bool start = false, neg = false;
  char c;
  num = 0;
  while ((c = getchar()) != EOF) {
    if (c == '-')
      start = neg = true;
    else if (c >= '0' && c <= '9') {
      start = true;
      num = num * 10 + c - '0';
    } else if (start)
      break;
  }
  if (neg) num = -num;
}
struct edge {
  int next, to, dist;
};
const int maxn = (int)(2e5) + 5;
int fr[maxn];
int ui[maxn], vi[maxn], wi[maxn];
int tmp[maxn], co[maxn], stk[maxn];
edge e[maxn << 1];
int tote, top, n, m;
inline void addone(int u, int v, int w) {
  ++tote;
  e[tote].next = fr[u];
  fr[u] = tote;
  e[tote].to = v;
  e[tote].dist = w;
}
inline void addedge(int u, int v, int w) {
  addone(u, v, w);
  addone(v, u, w);
}
int res, fl;
void dfs(int x, int c) {
  if (tmp[x] < 0) {
    tmp[x] = c;
    stk[++top] = x;
  } else {
    if (tmp[x] != c) fl = 0;
    return;
  }
  for (int i = fr[x]; i != -1; i = e[i].next) dfs(e[i].to, c ^ e[i].dist);
}
inline void chk() {
  fl = 1;
  top = 0;
  memset(tmp, -1, sizeof(tmp));
  for (int i = (1); i <= (n); i++)
    if (tmp[i] < 0) {
      dfs(i, 0);
      if (!fl) return;
      int cnt = 0;
      for (int j = (1); j <= (top); j++)
        if (tmp[stk[j]]) ++cnt;
      if (cnt > top - cnt) {
        for (int j = (1); j <= (top); j++) tmp[stk[j]] ^= 1;
      }
      top = 0;
    }
  int now = 0;
  for (int i = (1); i <= (n); i++)
    if (tmp[i]) ++now;
  if (now < res) {
    res = now;
    for (int i = (1); i <= (n); i++) co[i] = tmp[i];
  }
}
char s[10];
int main() {
  read(n);
  read(m);
  res = (int)(1e9);
  for (int i = (1); i <= (m); i++)
    scanf("%d%d%s", &ui[i], &vi[i], s), wi[i] = (s[0] == 'B');
  memset(fr, -1, sizeof(fr));
  tote = 0;
  for (int i = (1); i <= (m); i++) addedge(ui[i], vi[i], wi[i]);
  chk();
  memset(fr, -1, sizeof(fr));
  tote = 0;
  for (int i = (1); i <= (m); i++) addedge(ui[i], vi[i], wi[i] ^ 1);
  chk();
  if (res == (int)(1e9)) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", res);
  for (int i = (1); i <= (n); i++)
    if (co[i]) printf("%d ", i);
  putchar('\n');
  return 0;
}
