#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  char c;
  bool f = 0;
  while ((c = getchar()) < '0' || '9' < c) f |= (c == '-');
  for (x = (c ^ 48); '0' <= (c = getchar()) && c <= '9';
       x = (x << 1) + (x << 3) + (c ^ 48))
    ;
  if (f) x = -x;
}
template <class T>
inline T read(const T sample) {
  T x = 0;
  char c;
  bool f = 0;
  while ((c = getchar()) < '0' || '9' < c) f |= (c == '-');
  for (x = (c ^ 48); '0' <= (c = getchar()) && c <= '9';
       x = (x << 1) + (x << 3) + (c ^ 48))
    ;
  return f ? -x : x;
}
template <class T>
void fwrit(const T x) {
  if (x < 0) return (void)(putchar('-'), fwrit(-x));
  if (x > 9) fwrit(x / 10);
  putchar(x % 10 ^ 48);
}
template <class T>
inline T Max(const T x, const T y) {
  return x > y ? x : y;
}
template <class T>
inline T Min(const T x, const T y) {
  return x < y ? x : y;
}
template <class T>
inline T fab(const T x) {
  return x > 0 ? x : -x;
}
inline int gcd(const int a, const int b) { return b ? gcd(b, a % b) : a; }
inline void getInv(int inv[], const int lim, const int MOD) {
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= lim; ++i)
    inv[i] = 1ll * inv[MOD % i] * (MOD - MOD / i) % MOD;
}
inline long long mulMod(const long long a, const long long b,
                        const long long mod) {
  return ((a * b - (long long)((long double)a / mod * b + 1e-8) * mod) % mod +
          mod) %
         mod;
}
const int MAXN = 100000;
const int MAXM = 100000;
const int INF = (1 << 30) - 1;
struct edge {
  int to, nxt, c;
} e[MAXM * 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() {
  n = read(1), m = read(1);
  int u, v;
  char ch[5];
  for (signed i = (1), i_end_ = (m); i <= i_end_; ++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]; i; i = e[i].nxt)
    if (rever[e[i].to] != -1) Clear(e[i].to);
}
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 = goal ^ e[i].c ^ rev;
    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];
signed main() {
  Init();
  int ans1, ans2, f1, f2;
  bool flg;
  for (signed t = (0), t_end_ = (1); t <= t_end_; ++t) {
    flg = false;
    memset(rever, -1, sizeof rever);
    for (signed i = (1), i_end_ = (n); i <= i_end_; ++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 (signed i = (1), i_end_ = (n); i <= i_end_; ++i)
        if (rever[i] == 1) ++tot;
      if (tot > (n / 2)) {
        tot = n - tot;
        for (signed i = (1), i_end_ = (n); i <= i_end_; ++i)
          rever[i] = !rever[i];
      }
      if (tot < ans) {
        ans = tot;
        for (signed i = (1), i_end_ = (n); i <= i_end_; ++i) memo[i] = rever[i];
      }
    }
  }
  if (ans == INF)
    puts("-1");
  else {
    fwrit(ans), putchar('\n');
    for (signed i = (1), i_end_ = (n); i <= i_end_; ++i)
      if (memo[i]) fwrit(i), putchar(' ');
    putchar('\n');
  }
  return 0;
}
