#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int n, m;
vector<pair<int, int> > nei[N];
bool vis[2][N], num[2][N];
vector<vector<int> > ans[2];
bool first;
bool second;
void input() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    a--;
    b--;
    nei[a].push_back(make_pair(b, (c == 'R')));
    nei[b].push_back(make_pair(a, (c == 'R')));
  }
}
vector<int> cur[2];
bool dfs(int u, int r) {
  vis[r][u] = true;
  for (pair<int, int> uu : nei[u]) {
    if (vis[r][uu.first])
      if (num[r][uu.first] != 1 ^ num[r][u] ^ uu.second ^ r) return false;
    if (!vis[r][uu.first]) {
      num[r][uu.first] = 1 ^ num[r][u] ^ uu.second ^ r;
      cur[num[r][uu.first]].push_back(uu.first);
      if (!dfs(uu.first, r)) return false;
    }
  }
  return true;
}
bool solve(int r) {
  for (int i = 0; i < n; i++) {
    if (!vis[r][i]) {
      num[r][i] = 1;
      cur[0].resize(0);
      cur[1].resize(0);
      cur[1].push_back(i);
      if (!dfs(i, r)) return false;
      if (cur[0].size() > cur[1].size()) cur[0] = cur[1];
      ans[r].push_back(cur[0]);
    }
  }
  return true;
}
int main() {
  input();
  first = solve(0);
  second = solve(1);
  vector<vector<int> > final_ans;
  if (!first && !second) return cout << -1, 0;
  if (!first)
    final_ans = ans[1];
  else if (!second)
    final_ans = ans[0];
  else {
    int f = 0, s = 0;
    for (vector<int> v : ans[0]) f += v.size();
    for (vector<int> v : ans[1]) s += v.size();
    if (s < f)
      final_ans = ans[1];
    else
      final_ans = ans[0];
  }
  int ans_t = 0;
  for (vector<int> v : final_ans) ans_t += v.size();
  cout << ans_t << endl;
  for (vector<int> v : final_ans) {
    for (int i : v) cout << i + 1 << ' ';
  }
}
