#include <bits/stdc++.h>
using namespace std;
int n, m, cnt = 0;
bool pos = 1;
vector<vector<pair<int, int> > > adj;
vector<int> act, ans, ap;
void g(int i, int k) {
  if (act[i] != -1) {
    pos = pos && act[i] == k;
    return;
  }
  ap.push_back(i);
  act[i] = k, cnt += k;
  for (pair<int, int> p : adj[i]) g(p.first, k ^ p.second);
}
void f() {
  act.assign(n, -1);
  ans.clear();
  pos = 1;
  for (int(i) = (0); (i) < (n); (i)++)
    if (act[i] == -1) {
      cnt = 0;
      ap.clear();
      g(i, 0);
      if (cnt > ap.size() - cnt)
        for (int j : ap) act[j] ^= 1;
    }
  for (int(i) = (0); (i) < (n); (i)++)
    if (act[i]) ans.push_back(i);
  if (!pos) ans.assign(n * 2, 0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  adj.resize(n);
  for (int(i) = (0); (i) < (m); (i)++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    u--, v--;
    adj[u].push_back({v, c == 'R'});
    adj[v].push_back({u, c == 'R'});
  }
  f();
  vector<int> ans2 = ans;
  for (int(i) = (0); (i) < (n); (i)++)
    for (pair<int, int> &p : adj[i]) p.second ^= 1;
  f();
  if (ans2.size() < ans.size()) ans = ans2;
  if (ans.size() > n) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans.size() << endl;
  for (int i : ans) cout << i + 1 << " ";
}
