#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
int h[2][N];
vector<int> nd[2];
vector<pair<int, int> > v[N];
int dfs(int type, int x, int col, bool add) {
  if (h[type][x]) {
    if (h[type][x] == col + 1) return 0;
    return n + 1;
  }
  h[type][x] = col + 1;
  if (col and add) nd[type].push_back(x);
  int res = col;
  for (auto u : v[x]) {
    res += dfs(type, u.first, u.second ^ col, add);
    if (res > n) return n + 1;
  }
  return res;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    char c;
    scanf("%d %d %c", &x, &y, &c);
    v[x].push_back({y, c == 'B'});
    v[y].push_back({x, c == 'B'});
  }
  vector<int> ans(n, 0);
  for (int it = 0; it < 2; it++) {
    int res = 0;
    memset(h, 0, sizeof(h));
    for (int i = 1; i <= n; i++) {
      if (!h[0][i]) {
        int x = dfs(0, i, 0, 0);
        int y = dfs(1, i, 1, 0);
        if (x > n and y > n) {
          res = n + 1;
          break;
        }
        res += min(x, y);
      }
    }
    if (res > ans.size()) {
      for (int i = 1; i <= n; i++)
        for (auto &u : v[i]) u.second ^= 1;
      continue;
    }
    ans.clear();
    memset(h, 0, sizeof(h));
    for (int i = 1; i <= n; i++) {
      if (!h[0][i]) {
        nd[0].clear();
        nd[1].clear();
        int x = dfs(0, i, 0, 1);
        int y = dfs(1, i, 1, 1);
        if (x > y) swap(nd[0], nd[1]);
        for (auto u : nd[0]) ans.push_back(u);
      }
    }
    for (int i = 1; i <= n; i++)
      for (auto &u : v[i]) u.second ^= 1;
  }
  if (ans.size() == n) {
    puts("-1");
  } else {
    printf("%d\n", ans.size());
    for (auto x : ans) printf("%d ", x);
    puts("");
  }
  return 0;
}
