#include <bits/stdc++.h>
using namespace std;
const int infty = 123456789;
int n, m;
vector<pair<int, int> > ne[100005];
int ans[2];
int vis[2][100005];
const char *s = "";
int dfs(int v, int as, int t) {
  int ret = as;
  vis[t][v] = as;
  for (int i = 0; i < ne[v].size() && ret < infty; i++) {
    int s = ne[v][i].first, c = ne[v][i].second;
    if (vis[t][s] == -1) {
      if (c == t)
        ret += dfs(s, as, t);
      else
        ret += dfs(s, !as, t);
    } else {
      if (c == t && vis[t][s] != vis[t][v])
        return infty;
      else if (c != t && vis[t][s] == vis[t][v])
        return infty;
    }
  }
  return (ret < infty ? ret : infty);
}
void clear(int v, int t) {
  vis[t][v] = -1;
  for (int i = 0; i < ne[v].size(); i++) {
    int s = ne[v][i].first;
    if (vis[t][s] != -1) clear(s, t);
  }
}
int main() {
  scanf("%d %d\n", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    char c;
    scanf("%d %d %c\n", &u, &v, &c);
    u--;
    v--;
    ne[u].push_back(make_pair((v), (c == 'B')));
    ne[v].push_back(make_pair((u), (c == 'B')));
  }
  for (int t = 0; t < 2; t++) {
    for (int i = 0; i < n; i++) vis[t][i] = -1;
    ans[t] = 0;
    for (int i = 0; i < n; i++) {
      if (vis[t][i] == -1) {
        int mini = infty, mini_m;
        for (int m = 0; m < 2; m++) {
          int tmp = dfs(i, m, t);
          if (tmp < mini) {
            mini = tmp;
            mini_m = m;
          }
          clear(i, t);
        }
        if (mini == infty) {
          ans[t] = infty;
          break;
        }
        ans[t] += dfs(i, mini_m, t);
      }
    }
  }
  int best_t;
  if (ans[0] <= ans[1])
    best_t = 0;
  else
    best_t = 1;
  if (ans[best_t] == infty) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", ans[best_t]);
  for (int i = 0; i < n; i++) {
    if (vis[best_t][i]) {
      printf("%s%d", s, i + 1);
      s = " ";
    }
  }
  printf("\n");
  return 0;
}
