#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000009;
const int MAXN = 100000;
int n, m;
vector<pair<int, int> > graph[MAXN + 3];
bool vis[MAXN + 3];
bool color[MAXN + 3];
vector<int> ans[2], curr, output;
int counter;
void Read() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    char col;
    scanf("%d %d %c", &a, &b, &col);
    if (col == 'B')
      c = 1;
    else
      c = 0;
    graph[a].push_back(make_pair(b, c));
    graph[b].push_back(make_pair(a, c));
  }
}
void Clean() {
  for (int i = 1; i <= n; i++) vis[i] = false;
  for (int i = 1; i <= n; i++) color[i] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (int)graph[i].size(); j++)
      graph[i][j].second = (graph[i][j].second + 1) % 2;
  curr.clear();
}
bool Dfs(int v) {
  vis[v] = true;
  curr.push_back(v);
  if (color[v] == 0) counter++;
  for (int i = 0; i < (int)graph[v].size(); i++) {
    int u = graph[v][i].first;
    int sum = graph[v][i].second;
    if (!vis[u]) {
      color[u] = (sum - color[v] + 2) % 2;
      if (Dfs(u) == false) return false;
    } else {
      if (color[u] != (sum - color[v] + 2) % 2) return false;
    }
  }
  return true;
}
bool Solve(int ind) {
  for (int v = 1; v <= n; v++) {
    if (!vis[v]) {
      if (Dfs(v) == false) return false;
    }
    for (int i = 0; i < (int)curr.size(); i++) {
      if (color[curr[i]] == 0 && 2 * counter < (int)curr.size())
        ans[ind].push_back(curr[i]);
      else if (color[curr[i]] == 1 && 2 * counter >= (int)curr.size())
        ans[ind].push_back(curr[i]);
    }
    curr.clear();
    counter = 0;
  }
  return true;
}
int main() {
  Read();
  bool check0 = Solve(0);
  Clean();
  bool check1 = Solve(1);
  if (!check0 && !check1) {
    puts("-1");
    return 0;
  }
  if (!check1 || (ans[0].size() < ans[1].size() && check0))
    output = ans[0];
  else
    output = ans[1];
  printf("%d\n", (int)output.size());
  for (int i = 0; i < (int)output.size(); i++) {
    printf("%d ", output[i]);
  }
  puts("");
  return 0;
}
