#include <bits/stdc++.h>
using namespace std;
int fa[100005], re[100005], r[100005], sam[100005], dif[100005], Re[100005];
int n, m, ans, s;
char c[2];
struct edge {
  int u, v, p;
} e[100005];
inline int find(int k) {
  if (fa[k] == k) return k;
  int tmp = fa[k];
  fa[k] = find(fa[k]);
  r[k] = r[tmp] ^ r[k];
  return fa[k];
}
void check(int p) {
  for (int i = 1; i <= n; i++) fa[i] = i, r[i] = 0, sam[i] = dif[i] = 0;
  for (int i = 1; i <= m; i++) {
    int u = find(e[i].u), v = find(e[i].v);
    if (u == v) {
      if ((e[i].p == p) && (r[e[i].u] == r[e[i].v])) return;
      if ((e[i].p != p) && (r[e[i].u] != r[e[i].v])) return;
    } else {
      if (e[i].p == p)
        fa[u] = v, r[u] = r[e[i].v] ^ r[e[i].u] ^ 1;
      else
        fa[u] = v, r[u] = r[e[i].v] ^ r[e[i].u];
    }
  }
  for (int i = 1; i <= n; i++) {
    find(i);
    if (r[i])
      dif[fa[i]]++;
    else
      sam[fa[i]]++;
  }
  s = 0;
  for (int i = 1; i <= n; i++)
    if (dif[fa[i]] > sam[fa[i]]) {
      if (r[i] == 0) Re[++s] = i;
    } else {
      if (r[i] == 1) Re[++s] = i;
    }
  if ((ans == -1) || (s < ans)) {
    ans = s;
    for (int i = 1; i <= ans; i++) re[i] = Re[i];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%s", &e[i].u, &e[i].v, c);
    if (c[0] == 'B')
      e[i].p = 1;
    else
      e[i].p = 0;
  }
  for (int i = 1; i <= n; i++) fa[i] = i, sam[i] = 1, dif[i] = 0;
  ans = -1;
  check(1);
  check(0);
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) printf("%d ", re[i]);
}
