#include <bits/stdc++.h>
using namespace std;
template <typename Tk, typename Tv>
ostream& operator<<(ostream& os, const pair<Tk, Tv>& p) {
  os << "{" << p.first << ',' << p.second << "}";
  return os;
}
const int MAX = 100005;
const int MOD = 1000000000 + 7;
const int INF = 1000000000;
int countA, countB;
vector<vector<pair<int, char> > > G;
char x;
vector<int> component;
bool dfs(int u, bool colorU, bool marked[], int color[]) {
  component.push_back(u);
  color[u] = colorU;
  (color[u]) ? countA++ : countB++;
  marked[u] = true;
  bool nonBipartite = false;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first;
    char col = G[u][i].second;
    if (!marked[v]) {
      int newColor = colorU;
      if (col == x) newColor = !newColor;
      nonBipartite |= dfs(v, newColor, marked, color);
    } else {
      if (col == x) {
        if (color[v] == color[u]) return true;
      } else {
        if (color[v] != color[u]) return true;
      }
    }
  }
  return nonBipartite;
}
int solve(int color[]) {
  bool marked[MAX] = {};
  int cost = 0;
  for (int i = 0; i < G.size(); i++) {
    if (!marked[i]) {
      component.clear();
      countA = countB = 0;
      bool isNotPossible = dfs(i, true, marked, color);
      if (isNotPossible) return INF;
      if (countA > countB) {
        for (int i = 0; i < component.size(); i++) {
          int u = component[i];
          color[u] = !color[u];
        }
        swap(countA, countB);
      }
      cost += countA;
    }
  }
  return cost;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  G.resize(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].push_back(make_pair(b, c));
    G[b].push_back(make_pair(a, c));
  }
  x = 'R';
  int color1[MAX], color2[MAX];
  int cost1 = solve(color1);
  x = 'B';
  int cost2 = solve(color2);
  if ((cost1 == INF) && (cost2 == INF))
    cout << "-1" << endl;
  else if (cost1 < cost2) {
    printf("%d\n", cost1);
    for (int i = 0; i < n; i++) {
      if (color1[i]) printf("%d ", i + 1);
    }
    printf("\n");
  } else {
    printf("%d\n", cost2);
    for (int i = 0; i < n; i++) {
      if (color2[i]) printf("%d ", i + 1);
    }
    printf("\n");
  }
}
