#include <bits/stdc++.h>
using namespace std;
int n, m, notFind;
vector<pair<int, int>> edge[100001];
vector<int> ans[2], e[2];
int vis[100001];
void DFS(int u, int c, int vit) {
  vis[u] = c;
  e[c].push_back(u);
  for (auto k : edge[u]) {
    int v, col, nextCol;
    tie(v, col) = k;
    col = (col + c) % 2;
    nextCol = col == vit ? 0 : 1;
    if (vis[v] != -1) {
      if (vis[v] != nextCol) notFind = 1;
      continue;
    }
    DFS(v, nextCol, vit);
  }
}
bool solve(int vit) {
  memset(vis, -1, sizeof(vis));
  notFind = 0;
  for (int i = 1; i <= n; ++i) {
    if (vis[i] != -1) continue;
    e[0].clear();
    e[1].clear();
    DFS(i, 0, vit);
    if (notFind) return 0;
    if (e[0].size() > e[1].size()) swap(e[0], e[1]);
    for (auto j : e[0]) ans[vit].push_back(j);
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    char chr;
    cin >> u >> v >> chr;
    edge[u].push_back({v, chr == 'R'});
    edge[v].push_back({u, chr == 'R'});
  }
  bool n1, n2;
  int id = 0;
  n1 = solve(0);
  n2 = solve(1);
  if (!n1 && !n2) return cout << "-1", 0;
  if (!n1 || n1 && n2 && ans[0].size() > ans[1].size()) id = 1;
  cout << ans[id].size() << "\n";
  for (auto k : ans[id]) cout << k << " ";
  return 0;
}
