#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
int N, M, V[MAX];
bool VV[MAX], flag;
vector<pair<int, char> > adj[MAX];
vector<int> node[2];
void dfs(int cur, char c) {
  for (auto &it : adj[cur]) {
    int next = it.first;
    char t = it.second;
    if (V[next] == -1) {
      V[next] = (t == c) ? V[cur] : V[cur] ^ 1;
      node[V[next]].push_back(next);
      dfs(next, c);
    } else {
      int tt = (t == c) ? V[cur] : V[cur] ^ 1;
      if (V[next] != tt) {
        flag = false;
        return;
      }
    }
  }
}
vector<int> check(char c) {
  memset(V, -1, sizeof(V));
  vector<int> ret;
  for (int i = 0; i < N; ++i) {
    if (V[i] == -1) {
      flag = true;
      V[i] = 0;
      node[0].clear();
      node[1].clear();
      node[0].push_back(i);
      dfs(i, c);
      if (!flag) return vector<int>(N + 1);
      for (int i = 0; i < 2; ++i)
        if (node[i].size() <= node[i ^ 1].size()) {
          ret.insert(ret.end(), node[i].begin(), node[i].end());
          break;
        }
    }
  }
  return ret;
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; ++i) {
    int a, b;
    char c;
    scanf("%d%d %c", &a, &b, &c);
    --a, --b;
    adj[a].push_back({b, c});
    adj[b].push_back({a, c});
  }
  vector<int> ans(N + 1);
  for (auto c : string("RB")) {
    vector<int> temp = check(c);
    if (temp.size() < ans.size()) ans = move(temp);
  }
  if (ans.size() > N)
    printf("-1\n");
  else {
    printf("%d\n", ans.size());
    for (int it : ans) printf("%d ", it + 1);
  }
  return 0;
}
