#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
struct Edge {
  int u, v, c, cc, nxt;
  Edge() {}
  Edge(int _u, int _v, int _c, int _nxt) {
    u = _u;
    v = _v;
    c = cc = _c;
    nxt = _nxt;
  }
} edge[maxn << 1];
int head[maxn], n, m, ecnt, tmp, sum[2];
vector<int> res[2], tmp_vec, vecs[2];
void init() {
  ecnt = 0;
  memset(head, -1, sizeof(int) * (n + 1));
}
void addedge(int u, int v, int c) {
  edge[ecnt] = Edge(u, v, c, head[u]);
  head[u] = ecnt++;
  edge[ecnt] = Edge(v, u, c, head[v]);
  head[v] = ecnt++;
}
bool vis[maxn];
bool dfs(int u, bool paint, int c) {
  vis[u] = true;
  if (paint) {
    tmp++;
    tmp_vec.push_back(u);
    for (int i = head[u]; i != -1; i = edge[i].nxt) {
      edge[i].c ^= 1;
      edge[i ^ 1].c ^= 1;
    }
  }
  for (int i = head[u]; i != -1; i = edge[i].nxt) {
    int v = edge[i].v;
    if (edge[i].c != c) {
      if (vis[v]) return false;
      if (!dfs(v, true, c)) return false;
    } else if (!vis[v] && !dfs(v, false, c))
      return false;
  }
  return true;
}
void recover(int u) {
  vis[u] = false;
  for (int i = head[u]; i != -1; i = edge[i].nxt) {
    edge[i].c = edge[i ^ 1].c = edge[i].cc;
    int v = edge[i].v;
    if (vis[v]) recover(v);
  }
}
void handle(int u, int c, int id) {
  tmp = 0;
  int tmp1 = -1;
  for (int i = 0; i < 2; i++) vecs[i].clear();
  tmp_vec.clear();
  if (dfs(u, true, c)) {
    tmp1 = tmp;
    for (int i = 0; i < tmp1; i++) vecs[0].push_back(tmp_vec[i]);
  }
  recover(u);
  tmp = 0;
  int tmp2 = -1;
  tmp_vec.clear();
  if (dfs(u, false, c)) {
    tmp2 = tmp;
    for (int i = 0; i < tmp2; i++) vecs[1].push_back(tmp_vec[i]);
  }
  if (tmp1 == -1 && tmp2 == -1)
    sum[id] = -1;
  else if (tmp2 == -1 || tmp1 != -1 && tmp1 < tmp2) {
    sum[id] += tmp1;
    for (int i = 0; i < tmp1; i++) res[id].push_back(vecs[0][i]);
  } else {
    sum[id] += tmp2;
    for (int i = 0; i < tmp2; i++) res[id].push_back(vecs[1][i]);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  init();
  while (m--) {
    int u, v, c;
    char cc[2];
    scanf("%d%d%s", &u, &v, cc);
    c = (cc[0] == 'R');
    addedge(u, v, c);
  }
  for (int i = 1; i <= n && sum[0] != -1; i++) {
    if (!vis[i]) handle(i, 0, 0);
  }
  for (int i = 1; i <= n; i++) vis[i] = false;
  for (int i = 0; i < ecnt; i++) edge[i].c = edge[i].cc;
  for (int i = 1; i <= n && sum[1] != -1; i++) {
    if (!vis[i]) handle(i, 1, 1);
  }
  if (sum[0] == -1 && sum[1] == -1)
    puts("-1");
  else if (sum[1] == -1 || sum[0] != -1 && sum[0] < sum[1]) {
    printf("%d\n", sum[0]);
    for (int i = 0; i < sum[0]; i++) printf("%d ", res[0][i]);
  } else {
    printf("%d\n", sum[1]);
    for (int i = 0; i < sum[1]; i++) printf("%d ", res[1][i]);
  }
  return 0;
}
