#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> g[200000];
long long n, m;
bool ch = 1;
vector<long long> fans[2];
vector<long long> ans[2];
vector<long long> vis;
void dfs(long long s, long long color) {
  ans[vis[s]].push_back(s);
  for (auto it : g[s]) {
    long long node = it.first;
    if (vis[node] == 2) {
      if (it.second == color) {
        vis[node] = vis[s];
        dfs(node, color);
      } else {
        vis[node] = !vis[s];
        dfs(node, color);
      }
    } else {
      if (it.second == color) {
        if (vis[node] != vis[s]) ch = 0;
      } else if (vis[node] == vis[s])
        ch = 0;
    }
  }
}
long long can(long long color) {
  ch = 1;
  for (long long i = 1; i <= n; i++) vis[i] = 2;
  for (long long i = 1; i <= n; i++) {
    if (vis[i] == 2) {
      if (g[i].size() > 0) {
        ans[0].clear();
        ans[1].clear();
        vis[i] = 0;
        dfs(i, color);
        if (ans[0].size() < ans[1].size()) {
          for (auto it : ans[0]) fans[color].push_back(it);
        } else {
          for (auto it : ans[1]) fans[color].push_back(it);
        }
      }
    }
  }
  if (ch) {
    return fans[color].size();
  } else
    return n + 1;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  vis.resize(n + 1, 0);
  for (long long i = 0; i < m; i++) {
    long long u, v;
    char c;
    cin >> u >> v >> c;
    g[u].push_back({v, (c == 'R')});
    g[v].push_back({u, (c == 'R')});
  }
  long long a = can(0);
  long long b = can(1);
  if (a < b) {
    cout << fans[0].size() << "\n";
    for (auto it : fans[0]) cout << it << " ";
  } else {
    if (b == n + 1)
      cout << -1;
    else {
      cout << fans[1].size() << "\n";
      for (auto it : fans[1]) cout << it << " ";
    }
  }
}
