#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int logn = 10;
const int inf = (int)2e9 + 5;
const long long mod = (int)1e9 + 7;
const long long base = 2204234849;
const long long l_inf = (long long)4e18;
const long double pi = acos(-1.0);
const long double eps = 1e-12;
int n, m;
vector<pair<int, int> > g[maxn];
vector<int> g2[maxn];
int comp[maxn], it;
bool used[maxn], used2[maxn];
int sz[maxn];
int col[maxn];
bool painted[maxn];
vector<int> ans;
int best = inf;
void dfs1(int v) {
  used[v] = true;
  comp[v] = it;
  for (pair<int, int> u : g[v]) {
    if (!used[u.first] && u.second == 0) dfs1(u.first);
  }
}
void dfs2(int v, bool &flag) {
  sz[comp[v]]++;
  used[v] = true;
  for (pair<int, int> u : g[v]) {
    if (comp[v] == comp[u.first] && u.second == 1) {
      flag = false;
      return;
    }
    if (u.second == 1) {
      int x = comp[v], y = comp[u.first];
      g2[x].push_back(y);
      g2[y].push_back(x);
    }
  }
  for (pair<int, int> u : g[v]) {
    if (!used[u.first] && u.second == 0) dfs2(u.first, flag);
    if (!flag) return;
  }
}
bool good(int v, int dep) {
  col[v] = dep & 1;
  used[v] = true;
  for (int u : g2[v]) {
    if (!used[u] && !good(u, dep + 1)) return false;
    if (used[u] && col[v] == col[u]) return false;
  }
  return true;
}
void get(int v, int &a, int &b) {
  used[v] = true;
  col[v] == 0 ? a += sz[v] : b += sz[v];
  for (int u : g2[v])
    if (!used[u]) get(u, a, b);
}
void paint(int v, int c) {
  if (col[v] == c) painted[v] = true;
  used2[v] = true;
  for (int u : g2[v]) {
    if (!used2[u]) paint(u, c);
  }
}
void solve() {
  for (int i = 0; i < n; i++) {
    for (pair<int, int> &u : g[i]) u.second ^= 1;
    g2[i].clear();
  }
  memset(used, false, sizeof used);
  memset(comp, 0, sizeof comp);
  memset(sz, 0, sizeof sz);
  it = 0;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      dfs1(i);
      it++;
    }
  }
  memset(used, false, sizeof used);
  bool flag = true;
  for (int i = 0; i < n; i++)
    if (!used[i]) dfs2(i, flag);
  if (!flag) return;
  memset(used, false, sizeof used);
  memset(col, 0, sizeof col);
  for (int i = 0; i < it; i++)
    if (!used[i] && !good(i, 0)) return;
  memset(used, false, sizeof used);
  memset(used2, false, sizeof used2);
  memset(painted, false, sizeof painted);
  int cnt = 0;
  for (int i = 0; i < it; i++) {
    if (!used[i]) {
      int a = 0, b = 0;
      get(i, a, b);
      cnt += min(a, b);
      if (a < b) {
        paint(i, col[i]);
      } else {
        paint(i, col[i] ^ 1);
      }
    }
  }
  if (cnt < best) {
    best = cnt;
    ans.clear();
    for (int i = 0; i < n; i++)
      if (painted[comp[i]]) ans.push_back(i + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(12);
  cout << fixed;
  srand(566);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int v, u;
    char c;
    cin >> v >> u >> c;
    v--, u--;
    g[v].push_back(make_pair(u, c == 'B'));
    g[u].push_back(make_pair(v, c == 'B'));
  }
  solve();
  solve();
  if (best == inf) {
    cout << -1;
    exit(0);
  }
  cout << best << '\n';
  for (int a : ans) cout << a << ' ';
  return 0;
}
