#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int maxN = 1 << 17;
vector<int> g0[maxN], g1[maxN], K[maxN], *G, *H, temp[3];
int n, comp[maxN], col[maxN], sz[maxN];
bool fail, compInRes[maxN];
vector<int> res(maxN);
void normal(vector<int>& v) {
  sort((v).begin(), (v).end());
  v.resize(unique((v).begin(), (v).end()) - v.begin());
}
void dfsComp(int v, int c) {
  comp[v] = c;
  sz[c]++;
  for (int u : G[v])
    if (comp[u] == 0) dfsComp(u, c);
}
void dfsCol(int v, int c) {
  col[v] = c;
  temp[1 + c].push_back(v);
  for (int u : K[v]) {
    if (col[u] == col[v]) {
      fail = true;
      return;
    }
    if (col[u] == 0) dfsCol(u, -c);
  }
}
void solve() {
  for (int i = (1); i < (int)(n + 1); i++) {
    comp[i] = col[i] = sz[i] = compInRes[i] = 0;
    K[i].resize(0);
  }
  int c = 0;
  for (int i = (1); i < (int)(n + 1); i++)
    if (comp[i] == 0) dfsComp(i, ++c);
  for (int i = (1); i < (int)(n + 1); i++)
    for (int j : H[i]) {
      int a = comp[i], b = comp[j];
      if (a == b) return;
      K[a].push_back(b);
      K[b].push_back(a);
    }
  for (int i = (1); i < (int)(c + 1); i++) normal(K[i]);
  fail = false;
  for (int i = (1); i < (int)(c + 1); i++)
    if (col[i] == 0) {
      dfsCol(i, 1);
      int s[3] = {0, 0, 0};
      for (int j = (0); j < (int)(3); j++)
        for (int v : temp[j]) s[j] += sz[v];
      int j = s[0] < s[2] ? 0 : 2;
      for (int v : temp[j]) compInRes[v] = true;
      for (int j = (0); j < (int)(3); j++) temp[j].resize(0);
    }
  if (fail) return;
  vector<int> prop(0);
  for (int i = (1); i < (int)(n + 1); i++)
    if (compInRes[comp[i]]) prop.push_back(i);
  if (prop.size() < res.size()) res = prop;
}
void ans() {
  if (res.size() == maxN) {
    printf("-1\n");
    return;
  }
  printf("%d\n", (int)res.size());
  for (int v : res) printf("%d ", v);
  printf("\n");
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b;
    char c[3];
    scanf("%d%d%s", &a, &b, c);
    G = c[0] == 'R' ? g0 : g1;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  G = g0, H = g1;
  solve();
  swap(G, H);
  solve();
  ans();
  return 0;
}
