#include <bits/stdc++.h>
const int MAXN = 100000;
const int INF = (1 << 30) - 1;
struct edge {
  int to, nxt, c;
} e[MAXN * 2 + 5];
int tail[MAXN + 5], ecnt;
inline void add_edge(const int u, const int v, const int c) {
  e[++ecnt] = edge{v, tail[u], c};
  tail[u] = ecnt;
  e[++ecnt] = edge{u, tail[v], c};
  tail[v] = ecnt;
}
int n, m;
inline void Init() {
  scanf("%d %d", &n, &m);
  int u, v;
  char ch[5];
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d %s", &u, &v, ch);
    add_edge(u, v, ch[0] == 'R');
  }
}
int rever[MAXN + 5];
void Clear(const int u) {
  rever[u] = -1;
  for (int i = tail[u], v; i; i = e[i].nxt)
    if (rever[v = e[i].to] != -1) Clear(v);
}
int Judge(const int u, const int rev, const int goal) {
  int sum = rev, ret;
  rever[u] = rev;
  for (int i = tail[u], v, tore; i; i = e[i].nxt) {
    v = e[i].to;
    tore = rev ^ goal ^ e[i].c;
    if (rever[v] != -1 && rever[v] != tore) return -1;
    if (rever[v] == -1) {
      ret = Judge(v, tore, goal);
      if (ret == -1) return -1;
      sum += ret;
    }
  }
  return sum;
}
int ans = INF, memo[MAXN + 5];
int main() {
  Init();
  for (int t = 0; t < 2; ++t) {
    memset(rever, -1, sizeof rever);
    bool flg = false;
    int ans1, ans2;
    for (int i = 1; i <= n; ++i)
      if (rever[i] == -1) {
        Clear(i), ans1 = Judge(i, 0, t);
        Clear(i), ans2 = Judge(i, 1, t);
        if (ans1 == -1 && ans2 == -1) {
          flg = true;
          break;
        }
        if (ans2 == -1 || ans1 < ans2) {
          Clear(i);
          Judge(i, 0, t);
        }
      }
    if (!flg) {
      int tot = 0;
      for (int i = 1; i <= n; ++i)
        if (rever[i]) ++tot;
      if (tot > (n / 2)) {
        tot = n - tot;
        for (int i = 1; i <= n; ++i) rever[i] = !rever[i];
      }
      if (tot < ans) {
        ans = tot;
        for (int i = 1; i <= n; ++i) memo[i] = rever[i];
      }
    }
  }
  if (ans == INF)
    puts("-1");
  else {
    printf("%d\n", ans);
    for (int i = 1; i <= n; ++i)
      if (memo[i]) printf("%d ", i);
  }
  return 0;
}
