#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(48 + x % 10);
}
inline void writeln(int x) {
  write(x);
  putchar('\n');
}
inline void writebl(int x) {
  write(x);
  putchar(' ');
}
const int maxn = 2e5 + 5;
struct edge {
  int v, w, next;
} e[maxn];
int head[maxn], ecnt;
int color[maxn], out[maxn];
int tot1, tot2, n, ans = -1, want;
queue<int> q;
void dfs(int x) {
  if (color[x])
    ++tot1;
  else
    ++tot2;
  q.push(x);
  for (register int i = head[x]; i; i = e[i].next) {
    int v = e[i].v, w = color[x] ^ want ^ e[i].w;
    if (color[v] < 0) {
      color[v] = w;
      dfs(v);
      if (tot1 < 0) return;
    } else if (color[v] != w) {
      tot1 = -1;
      return;
    }
  }
}
inline void solve(int op) {
  want = op;
  int res = 0;
  memset(color, -1, sizeof(color));
  for (register int i = 1; i <= n; ++i)
    if (color[i] < 0) {
      while (q.size()) q.pop();
      tot1 = tot2 = 0;
      color[i] = 1;
      dfs(i);
      if (tot1 < 0) {
        res = -1;
        break;
      }
      res += tot1 < tot2 ? tot1 : tot2;
      register bool t = tot1 > tot2;
      while (q.size()) color[q.front()] ^= t, q.pop();
    }
  if ((ans == -1 || ans > res) && res != -1) {
    for (register int i = 1; i <= n; ++i) out[i] = color[i];
    ans = res;
  }
}
int main() {
  n = read();
  int m = read();
  for (register int i = 1; i <= m; ++i) {
    int u = read(), v = read(), w;
    char ch = getchar();
    while (ch != 'R' && ch != 'B') ch = getchar();
    w = ch == 'R';
    e[++ecnt] = (edge){v, w, head[u]}, head[u] = ecnt;
    e[++ecnt] = (edge){u, w, head[v]}, head[v] = ecnt;
  }
  solve(0);
  solve(1);
  writeln(ans);
  if (ans != -1)
    for (register int i = 1; i <= n; ++i)
      if (out[i]) writebl(i);
}
