#include <bits/stdc++.h>
using namespace std;
template <class T>
void minimize(T& x, const T& y) {
  if (y < x) x = y;
}
template <class T>
void maximize(T& x, const T& y) {
  if (x < y) x = y;
}
template <class T>
T sqr(T x) {
  return x * x;
}
const long double EPS = acos(-1.0);
const int INF = (int)1e9 + 5;
const long long LINF = (long long)1e18 + 5;
const int N = 100500;
int n, m;
vector<pair<int, char>> g[N];
int color[N];
char diffChar;
bool isBad;
vector<int> comp;
int bestLen = INF;
vector<int> result;
void dfs(int x, int c) {
  if (color[x] != -1) {
    if (color[x] != c) {
      isBad = true;
    }
    return;
  }
  comp.push_back(x);
  color[x] = c;
  for (auto p : g[x]) {
    dfs(p.first, c ^ (p.second == diffChar ? 1 : 0));
  }
}
void proc(char _diff) {
  memset(color, 255, sizeof(color));
  diffChar = _diff;
  isBad = false;
  vector<int> trueColor;
  for (int i = 1; i <= n; i++) {
    if (color[i] == -1) {
      comp.clear();
      dfs(i, 0);
      vector<int> a, b;
      for (int v : comp) {
        if (color[v] == 0)
          a.push_back(v);
        else
          b.push_back(v);
      }
      if (a.size() > b.size()) swap(a, b);
      for (int v : a) {
        trueColor.push_back(v);
      }
    }
  }
  if (!isBad && bestLen > (int)trueColor.size()) {
    bestLen = (int)trueColor.size();
    result = trueColor;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    char c;
    scanf("%d%d %c", &x, &y, &c);
    g[x].push_back(make_pair(y, c));
    g[y].push_back(make_pair(x, c));
  }
  proc('R');
  proc('B');
  if (bestLen == INF) {
    cout << "-1" << endl;
  } else {
    cout << (int)result.size() << endl;
    for (int x : result) {
      cout << x << " ";
    }
    cout << endl;
  }
  return 0;
}
