#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, m, C;
int c[MAXN];
int ans[2][MAXN], anstot[2];
int wdnmdtot[2], wdnmd[2][MAXN], wd;
int Read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x * 10) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
void Put1(int x) {
  if (x > 9) Put1(x / 10);
  putchar(x % 10 ^ 48);
}
void Put(int x, char c = -1) {
  if (x < 0) putchar('-'), x = -x;
  Put1(x);
  if (c >= 0) putchar(c);
}
template <typename T>
T Max(T x, T y) {
  return x > y ? x : y;
}
template <typename T>
T Min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
T Abs(T x) {
  return x < 0 ? -x : x;
}
int head[MAXN], tot;
struct edge {
  int v, c, nxt;
} e[MAXN << 1];
void Add_Edge(int x, int y, int c) {
  e[++tot].v = y;
  e[tot].nxt = head[x];
  e[tot].c = c;
  head[x] = tot;
}
void Add_Double_Edge(int x, int y, int c) {
  Add_Edge(x, y, c);
  Add_Edge(y, x, c);
}
char gc() {
  char c = getchar();
  while (c != 'B' && c != 'R') c = getchar();
  return c;
}
void fuzhi(int x) {
  c[x] = -1;
  for (int i = head[x]; i; i = e[i].nxt)
    if (c[e[i].v] != -1) fuzhi(e[i].v);
}
bool dfs(int x) {
  if (c[x]) wdnmd[wd][++wdnmdtot[wd]] = x;
  for (int i = head[x]; i; i = e[i].nxt) {
    int toc = C ^ e[i].c ^ c[x];
    if (c[e[i].v] == -1) {
      c[e[i].v] = toc;
      if (!dfs(e[i].v)) return 0;
    } else if (c[e[i].v] == toc)
      continue;
    else
      return 0;
  }
  return 1;
}
void print(int x) {
  Put(anstot[x], '\n');
  for (int i = 1; i <= anstot[x]; ++i) Put(ans[x][i], ' ');
}
int main() {
  n = Read();
  m = Read();
  for (int i = 1; i <= m; ++i) {
    int u = Read(), v = Read();
    Add_Double_Edge(u, v, gc() == 'R');
  }
  int fk = 0;
  for (C = 0; C <= 1; ++C) {
    for (int i = 1; i <= n; ++i) c[i] = -1;
    for (int i = 1; i <= n; ++i) {
      if (c[i] == -1) {
        c[i] = 0;
        wdnmdtot[0] = wd = 0;
        if (!dfs(i)) {
          fuzhi(i);
          wdnmdtot[0] = n + 1;
          c[i] = 1;
          wdnmdtot[1] = 0;
          wd = 1;
          if (!dfs(i)) {
            fk += 1 + C;
            break;
          }
        } else {
          fuzhi(i);
          c[i] = 1;
          wdnmdtot[1] = 0;
          wd = 1;
          if (!dfs(i)) wdnmdtot[1] = n + 1;
        }
        if (wdnmdtot[0] < wdnmdtot[1])
          for (int j = 1; j <= wdnmdtot[0]; ++j)
            ans[C][++anstot[C]] = wdnmd[0][j];
        else
          for (int j = 1; j <= wdnmdtot[1]; ++j)
            ans[C][++anstot[C]] = wdnmd[1][j];
      }
    }
  }
  if (!fk)
    print(anstot[0] > anstot[1]);
  else if (fk == 1)
    print(1);
  else if (fk == 2)
    print(0);
  else
    Put(-1);
  return 0;
}
