#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int n, m, use[2][MAXN], ans[2][MAXN], d[2][MAXN], num[2];
int tot, Last[MAXN], Next[MAXN * 2], Go[MAXN * 2], Col[MAXN * 2];
bool flag[2][MAXN];
void link(int u, int v, int c) {
  Next[++tot] = Last[u], Last[u] = tot, Go[tot] = v, Col[tot] = c;
}
bool dfs(int now, int sig, int ansc, int ty) {
  d[ty][++d[ty][0]] = now;
  flag[ty][now] = 1;
  use[ty][now] = sig;
  num[ty] += sig;
  for (int p = Last[now]; p; p = Next[p]) {
    int v = Go[p], c = Col[p], nsig;
    if (c == ansc && !sig || c != ansc && sig)
      nsig = 0;
    else
      nsig = 1;
    if (flag[ty][v] && use[ty][v] != nsig) return 0;
    if (flag[ty][v]) continue;
    if (!dfs(v, nsig, ansc, ty)) return 0;
  }
  return 1;
}
bool solve(int col) {
  for (int i = 1; i <= n; i++) flag[0][i] = flag[1][i] = 0;
  for (int i = 1; i <= n; i++) {
    if (flag[0][i]) continue;
    for (int j = 0; j < 2; j++) {
      d[j][0] = num[j] = 0;
      if (!dfs(i, j, col, j)) d[j][0] = -1;
    }
    if (d[0][0] == -1 && d[1][0] == -1) return 0;
    int id;
    if (d[0][0] == -1 || d[1][0] != -1 && num[1] < num[0])
      id = 1;
    else
      id = 0;
    for (int j = 1; j <= d[id][0]; j++) {
      int v = d[id][j];
      flag[0][v] = flag[1][v] = 1;
      if (use[id][v] == 1) ans[col][++ans[col][0]] = v;
    }
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    char ch;
    scanf("%d%d", &u, &v);
    ch = getchar();
    while (ch != 'R' && ch != 'B') ch = getchar();
    link(u, v, ch == 'R');
    link(v, u, ch == 'R');
  }
  bool get = 0;
  for (int i = 0; i < 2; i++)
    if (!solve(i)) ans[i][0] = -1;
  if (ans[0][0] == -1 && ans[1][0] == -1) {
    printf("-1\n");
    return 0;
  }
  int id;
  if (ans[0][0] == -1 || ans[1][0] != -1 && ans[1][0] < ans[0][0])
    id = 1;
  else
    id = 0;
  printf("%d\n", ans[id][0]);
  for (int i = 1; i <= ans[id][0]; i++) printf("%d ", ans[id][i]);
  printf("\n");
}
