#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10000000000")
#pragma GCC optimize("O3")
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007LL;
const long long INF2 = 1LL << 62LL;
const long double EPS = 1e-9;
const int SIZE = 300010;
mt19937 rng(time(0));
uniform_int_distribution<int> uid(-1000000000, 1000000000);
int n;
vector<int> ans1, ans2, vertex[2];
vector<pair<int, bool> > g[SIZE];
int used[SIZE], incorrect;
void dfs(int v, int color) {
  if (incorrect) return;
  if (used[v]) {
    if (used[v] != color) incorrect = 1;
    return;
  }
  used[v] = color;
  vertex[color - 1].push_back(v);
  for (auto& i : g[v]) {
    if (i.second)
      dfs(i.first, 3 - color);
    else
      dfs(i.first, color);
  }
}
void solve(vector<int>& ans) {
  fill(used, used + n, 0);
  incorrect = 0;
  for (int i = 0; i < n; ++i) {
    if (used[i]) continue;
    vertex[0].clear();
    vertex[1].clear();
    dfs(i, 1);
    if (incorrect) {
      ans.resize(n + 10);
      return;
    }
    if (vertex[0].size() <= vertex[1].size())
      ans.insert(ans.end(), (vertex[0]).begin(), (vertex[0]).end());
    else
      ans.insert(ans.end(), (vertex[1]).begin(), (vertex[1]).end());
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> n >> m;
  for (int rep_iter = 0; rep_iter < m; ++rep_iter) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    c = (c == 'R');
    --a;
    --b;
    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }
  solve(ans1);
  for (int i = 0; i < n; ++i) {
    for (auto& j : g[i]) j.second = !j.second;
  }
  solve(ans2);
  if (ans1.size() > ans2.size()) ans1 = ans2;
  if (ans1.size() > n) {
    cout << -1;
    return 0;
  }
  sort((ans1).begin(), (ans1).end());
  cout << ans1.size() << '\n';
  for (auto& i : ans1) cout << i + 1 << ' ';
  return 0;
}
