#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = int(2e5) + 10;
const int M = int(1e5) + 5;
const int INF = int(1e9);
int U[N], V[N], W[N], vis[N], D[N], comp[N], val[N], ans[N], parent;
vector<int> g[N], rg[N], G[N], nodes;
int n, m;
int adj(int u, int e) { return U[e] ^ V[e] ^ u; }
void get(int u) {
  nodes.push_back(u);
  nodes.push_back(u + M);
  vis[u] = 1;
  for (auto e : G[u]) {
    int w = adj(u, e);
    if (vis[w]) continue;
    get(w);
  }
}
int NOT(int u) {
  if (u < M)
    return u + M;
  else
    return u - M;
}
void addEdge(int u, int v) {
  u = NOT(u);
  g[u].push_back(v);
  rg[v].push_back(u);
  u = NOT(u);
  v = NOT(v);
  swap(u, v);
  g[u].push_back(v);
  rg[v].push_back(u);
}
void clear(int u) {
  g[u].clear(), rg[u].clear(), vis[u] = 0, val[u] = 0, comp[u] = 0;
  for (auto e : G[u]) D[e] = 0;
}
vector<int> order, component;
void dfs1(int u) {
  vis[u] = 1;
  for (auto w : g[u])
    if (!vis[w]) dfs1(w);
  order.push_back(u);
}
void dfs2(int u) {
  vis[u] = 1;
  comp[u] = parent;
  for (auto w : rg[u])
    if (!vis[w]) dfs2(w);
}
int go(int t) {
  for (auto u : nodes) clear(u);
  for (auto u : nodes)
    for (auto e : G[u])
      if (!D[e]) {
        D[e] = 1;
        if (W[e] == t)
          addEdge(U[e], V[e]), addEdge(NOT(U[e]), NOT(V[e]));
        else
          addEdge(U[e], NOT(V[e])), addEdge(NOT(U[e]), V[e]);
      }
  order.clear();
  for (auto i : nodes)
    if (!vis[i]) dfs1(i);
  for (auto u : nodes) vis[u] = 0;
  reverse(order.begin(), order.end());
  vector<int> Cmp;
  for (auto i : order) {
    if (!vis[i]) parent = i, Cmp.push_back(i), dfs2(i);
  }
  for (auto u : nodes) {
    if (comp[u] == comp[NOT(u)]) return INF;
  }
  reverse(Cmp.begin(), Cmp.end());
  int a = 0, b = 0;
  for (auto u : Cmp) {
    if (!val[u]) {
      val[u] = 1;
      val[comp[NOT(u)]] = -1;
    }
  }
  for (auto u : nodes)
    if (u < M) (val[comp[u]] == 1) ? a++ : b++;
  int V = (a > b ? 0 : 1);
  for (auto u : nodes)
    if (u < M && val[comp[u]] == 1)
      ans[u] = V;
    else if (u < M)
      ans[u] = 1 - V;
  return min(a, b);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    char x;
    scanf("%d %d %c", U + i, V + i, &x);
    G[U[i]].push_back(i);
    G[V[i]].push_back(i);
    W[i] = (x == 'R' ? 1 : 0);
  }
  long long int Ans1 = 0, Ans2 = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      nodes.clear();
      get(i);
      Ans1 += go(0);
      Ans2 += go(1);
    }
  long long int Ans = min(Ans1, Ans2);
  if (Ans >= INF)
    puts("-1");
  else {
    printf("%lld\n", Ans);
    int t = (Ans == Ans1 ? 0 : 1);
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++)
      if (!vis[i]) {
        nodes.clear();
        get(i);
        go(t);
      }
    for (int i = 1; i <= n; i++)
      if (ans[i]) printf("%d ", i);
    puts("");
  }
  return 0;
}
