#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m;
int tp[N][2];
vector<pair<pair<int, int>, char>> ds;
vector<pair<int, int>> adj[N][2];
vector<pair<int, int>> pa[2];
int pa_chosen;
bool chosen[N], chosen_save[N];
int dfs(int u, int u2) {
  pa[pa_chosen].push_back({u, u2});
  if (tp[u][1 - u2] != 0 && tp[u][1 - u2] == tp[u][u2]) return -1;
  int dem = 0;
  if (u2 == 1) dem++;
  for (auto ed : adj[u][u2]) {
    int v = ed.first;
    int cc = ed.second;
    if (tp[v][cc] == 0) {
      tp[v][cc] = tp[u][u2];
      int tmp = dfs(v, cc);
      if (tmp == -1) return -1;
      dem += tmp;
    }
  }
  return dem;
}
void make_edge(int u, int u2, int v, int v2) {
  adj[u][u2].push_back({v, v2});
  adj[v][v2].push_back({u, u2});
}
int solve(char code) {
  for (int i = 1; i <= n; i++) {
    adj[i][0].clear();
    adj[i][1].clear();
    tp[i][0] = tp[i][1] = 0;
    chosen[i] = false;
  }
  for (auto &ed : ds) {
    int u = ed.first.first;
    int v = ed.first.second;
    char cc = ed.second;
    if (cc == code) {
      make_edge(u, 0, v, 0);
      make_edge(u, 1, v, 1);
    } else {
      make_edge(u, 1, v, 0);
      make_edge(u, 0, v, 1);
    }
  }
  int ans = 0;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (tp[i][0] != 0) continue;
    cnt++;
    tp[i][0] = cnt;
    pa[0].clear();
    pa[1].clear();
    pa_chosen = 0;
    int res = dfs(i, 0);
    if (res == -1) return -1;
    pa_chosen = 1;
    cnt++;
    tp[i][1] = cnt;
    int res2 = dfs(i, 1);
    if (res < res2) {
      ans += res;
      for (auto v : pa[0]) {
        if (v.second == 1) chosen[v.first] = true;
      }
    } else {
      ans += res2;
      for (auto v : pa[1]) {
        if (v.second == 1) chosen[v.first] = true;
      }
    }
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    char c;
    scanf("%d %d %c", &u, &v, &c);
    ds.push_back({{u, v}, c});
  }
  int ans = solve('B');
  for (int i = 1; i <= n; i++) chosen_save[i] = chosen[i];
  int ans2 = solve('R');
  if (ans2 >= 0 && (ans < 0 || ans2 < ans))
    ans = ans2;
  else {
    for (int i = 1; i <= n; i++) chosen[i] = chosen_save[i];
  }
  printf("%d\n", ans);
  if (ans >= 0) {
    for (int i = 1; i <= n; i++)
      if (chosen[i]) printf("%d ", i);
  }
  return 0;
}
