#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
int n, m;
bool visited[2][100000 + 7];
bool flipped[100000 + 7];
bool flipped_sol[100000 + 7];
vector<map<int, int>> edges;
vector<map<int, int>> edges0;
map<int, int> bfs(int x, int flip, int cc) {
  vector<int> Q;
  map<int, int> flipped_now;
  Q.push_back(x);
  int k = 0;
  visited[flip][x] = 1;
  if (flip) flipped_now[x] = 1;
  int fx, fu;
  while (k < Q.size()) {
    int x = Q[k];
    if (flipped_now.find(x) != flipped_now.end())
      fx = 1;
    else
      fx = 0;
    for (auto u : edges[x]) {
      if (flipped_now.find(u.first) != flipped_now.end())
        fu = 1;
      else
        fu = 0;
      if (!visited[flip][u.first]) {
        visited[flip][u.first] = 1;
        if (u.second ^ fx ^ fu != cc) {
          flipped_now[u.first] = 1;
        }
        Q.push_back(u.first);
      } else {
        if (u.second ^ fx ^ fu != cc) {
          flipped_now[-1] = 1;
        }
      }
    }
    k++;
  }
  return flipped_now;
}
int main() {
  scanf("%d%d", &n, &m);
  edges.resize(n + 1);
  for (int i = 0; i < m; i++) {
    int u, v;
    char c;
    scanf("%d%d %c\n", &u, &v, &c);
    if (c == 'R') {
      edges[u][v] = 1;
      edges[v][u] = 1;
    } else {
      edges[u][v] = 0;
      edges[v][u] = 0;
    }
  }
  int min_flips = n + 1;
  edges0 = edges;
  int a, b;
  for (int color = 0; color < 2; color++) {
    memset(visited[0], 0, n + 1);
    memset(visited[1], 0, n + 1);
    memset(flipped, 0, n + 1);
    edges = edges0;
    bool good = 1;
    for (int i = 1; i <= n; i++) {
      if (!visited[0][i] || !visited[1][i]) {
        map<int, int> a = bfs(i, 0, color);
        map<int, int> b = bfs(i, 1, color);
        if (a.find(-1) != a.end() && b.find(-1) != b.end()) {
          good = 0;
          break;
        } else if (a.size() < b.size() || b.find(-1) != b.end()) {
          for (auto u : a) flipped[u.first] = 1;
        } else {
          for (auto u : b) flipped[u.first] = 1;
        }
      }
    }
    int flips = 0;
    for (int i = 1; i <= n; i++) flips += flipped[i];
    if (good && flips < min_flips) {
      min_flips = flips;
      memcpy(flipped_sol, flipped, n + 1);
    }
  }
  if (min_flips < n + 1) {
    printf("%d\n", min_flips);
    for (int i = 1; i <= n; i++)
      if (flipped_sol[i]) printf("%d ", i);
  } else
    printf("-1");
  return 0;
}
