#include <bits/stdc++.h>
using namespace std;
const int NM = 1e5 + 10;
int color[NM];
vector<pair<int, char> > adj[NM];
bool dfs(int u, bool c, char type, vector<int> &all) {
  if (color[u] != -1) return (color[u] == c);
  all.push_back(u);
  color[u] = c;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    char edge = adj[u][i].second;
    if (type == edge) {
      if (!dfs(v, c, type, all)) return false;
    } else {
      if (!dfs(v, !c, type, all)) return false;
    }
  }
  return true;
}
vector<int> solve(int n, char type) {
  vector<int> ret;
  memset(color, -1, sizeof(color));
  for (int i = 1; i <= n; i++) {
    if (color[i] == -1) {
      vector<int> all;
      if (!dfs(i, 0, type, all)) {
        for (int j = 0; j <= n; j++) {
          ret.push_back(-1);
        }
        return ret;
      } else {
        int cnt[2] = {0, 0};
        for (int j = 0; j < all.size(); j++) {
          cnt[color[all[j]]]++;
        }
        if (cnt[0] > cnt[1]) {
          for (int j = 0; j < all.size(); j++) {
            color[all[j]] ^= 1;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (color[i] == 0) {
      ret.push_back(i);
    }
  }
  return ret;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    char c;
    scanf("%d %d %c", &u, &v, &c);
    adj[u].push_back(make_pair(v, c));
    adj[v].push_back(make_pair(u, c));
  }
  vector<int> a = solve(n, 'R'), b = solve(n, 'B');
  if (a.size() > n && b.size() > n) {
    printf("-1\n");
  } else {
    if (a.size() > b.size()) {
      a.swap(b);
    }
    printf("%d\n", a.size());
    for (int i = 0; i < a.size(); i++) {
      printf("%d ", a[i]);
    }
    printf("\n");
  }
  return 0;
}
