#include <bits/stdc++.h>
using namespace std;
const int INF = 1e6;
const int maxn = 2e5 + 5;
struct Nod {
  int b, next, val;
  void init(int b, int val, int next) {
    this->b = b;
    this->val = val;
    this->next = next;
  }
} buf[maxn];
int n, m, len, E[maxn], mark[maxn];
int chn[2][maxn], sz[2];
int part[2][maxn], tot[2];
void init() {
  len = 0;
  memset(E, -1, sizeof(E));
}
void add_edge(int a, int b, int c) {
  buf[len].init(b, c, E[a]);
  E[a] = len++;
  buf[len].init(a, c, E[b]);
  E[b] = len++;
}
bool dfs(int u, int target) {
  int i, v, w, p, cnt = 0, num = 0;
  for (i = E[u]; i != -1; i = buf[i].next) {
    v = buf[i].b;
    w = buf[i].val;
    if (mark[v] != -1) {
      num++;
      cnt += ((w ^ mark[v]) != target);
    }
  }
  if (num == 0) {
    tot[0] = tot[1] = 0;
    part[0][tot[0]++] = u;
  } else if (cnt == 0 || cnt == num) {
    p = (cnt == num);
    mark[u] = p;
    part[p][tot[p]++] = u;
  } else {
    return false;
  }
  bool res = true;
  for (i = E[u]; i != -1; i = buf[i].next) {
    v = buf[i].b;
    if (mark[v] == -1) res &= dfs(v, target);
  }
  return res;
}
int main() {
  int i, j, cas;
  int u, v;
  char s[5];
  scanf("%d%d", &n, &m);
  init();
  while (m--) {
    scanf("%d %d %c", &u, &v, &s[0]);
    add_edge(u, v, s[0] == 'R');
  }
  for (int k = 0, f; k < 2; k++) {
    memset(mark, -1, sizeof(mark));
    sz[k] = 0;
    for (i = 1; i <= n; i++) {
      if (mark[i] != -1) continue;
      mark[i] = 0;
      if (!dfs(i, k)) {
        sz[k] = INF;
        break;
      }
      f = tot[0] > tot[1];
      memcpy(chn[k] + sz[k], part[f], tot[f] * sizeof(int));
      sz[k] += tot[f];
    }
  }
  if (min(sz[0], sz[1]) >= INF) {
    puts("-1");
    return 0;
  }
  if (sz[0] <= sz[1]) {
    printf("%d\n", sz[0]);
    for (i = 0; i < sz[0]; i++) printf("%d ", chn[0][i]);
  } else {
    printf("%d\n", sz[1]);
    for (i = 0; i < sz[1]; i++) printf("%d ", chn[1][i]);
  }
  return 0;
}
