#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int mod = 1000000007;
const int inf = (1 << 30);
const long long infll = (1LL << 60);
int n, m;
vector<pair<int, int> > adj[MAXN];
int vis[MAXN];
vector<int> res[2];
bool fucked = false;
void dfs(int u, int p, int cl) {
  if (vis[u]) {
    if (vis[u] != p) fucked = true;
    return;
  }
  vis[u] = p;
  res[p - 1].push_back(u);
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    int c = adj[u][i].second;
    if (c == cl)
      dfs(v, p, cl);
    else
      dfs(v, p ^ 3, cl);
  }
}
vector<int> ret;
bool solve(int cl) {
  memset(vis, 0, sizeof vis);
  ret = vector<int>();
  for (int i = 1; i <= n; i++) {
    fucked = false;
    if (vis[i]) continue;
    res[0] = res[1] = vector<int>();
    dfs(i, 1, cl);
    int f = 0;
    if (res[1].size() < res[0].size()) f = 1;
    if (fucked) return false;
    ret.insert(ret.end(), res[f].begin(), res[f].end());
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v, cl;
    char s[2];
    scanf("%d%d%s", &u, &v, s);
    cl = s[0] == 'R' ? 1 : 0;
    adj[u].emplace_back(v, cl);
    adj[v].emplace_back(u, cl);
  }
  vector<int> ans = {-1};
  if (solve(0)) ans = ret;
  if (solve(1)) {
    if (ret.size() <= ans.size() || (ans.size() == 1 && ans[0] == -1))
      ans = ret;
  }
  if (ans.size() == 1 && ans[0] == -1)
    puts("-1");
  else {
    printf("%d\n", ans.size());
    for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  }
}
