#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000006;
vector<pair<int, char> > V[MAXN];
bool vis[MAXN];
int n, m;
vector<int> ans, tt, teraz;
int ct;
int odw[MAXN];
bool czy[MAXN];
char jak;
bool ok = 1;
void dfs(int u) {
  if (czy[u]) teraz.push_back(u + 1);
  assert(odw[u] != ct);
  odw[u] = ct;
  for (auto it = (V[u]).begin(); it != (V[u]).end(); ++it) {
    bool tamten = (it->second != jak) ^ czy[u];
    if (odw[it->first] == ct) {
      if (tamten != czy[it->first]) {
        ok = 0;
        return;
      }
    } else {
      czy[it->first] = tamten;
      dfs(it->first);
      if (!ok) return;
    }
  }
}
void probuj(char c) {
  jak = c;
  tt.clear();
  int startct = ct;
  for (int i = 0; i < (n); ++i)
    if (odw[i] <= startct) {
      bool ktos = 0;
      vector<int> best;
      for (int j = 0; j < (2); ++j) {
        teraz.clear();
        ++ct;
        ok = 1;
        czy[i] = j;
        dfs(i);
        if (ok && (ktos == 0 || best.size() > teraz.size())) {
          ktos = 1;
          best = teraz;
        }
      }
      if (!ktos) return;
      for (auto it = (best).begin(); it != (best).end(); ++it)
        tt.push_back(*it);
    }
  if (tt.size() < ans.size()) ans = tt;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (m); ++i) {
    int a, b;
    char c;
    scanf("%d %d %c", &a, &b, &c);
    --a;
    --b;
    V[a].push_back({b, c});
    V[b].push_back({a, c});
  }
  ans.resize(n + 2);
  probuj('R');
  probuj('B');
  if (ans.size() == n + 2)
    puts("-1");
  else {
    printf("%lu\n", ans.size());
    for (auto it = (ans).begin(); it != (ans).end(); ++it) printf("%d ", *it);
    puts("");
  }
  return 0;
}
