#include <bits/stdc++.h>
#pragma warning(disable : 4244 4267 4018 4996 4800)
using namespace std;
istream& in = cin;
ostream& out = cout;
template <class T>
void read(T& t) {
  for (auto& x : t) in >> x;
}
template <class T>
int sz(T const& t) {
  return (int)t.size();
}
int n, m;
vector<vector<int>> edges;
int col;
vector<vector<int>> color;
vector<int> mark, toggled, visited;
bool dfs(int v) {
  mark[v] = 1;
  visited.push_back(v);
  for (int idx = 0; idx < edges[v].size(); ++idx) {
    int to = edges[v][idx];
    int c = color[v][idx];
    if (toggled[v]) c = 1 - c;
    if (mark[to]) {
      if (toggled[to] != (c != col)) return false;
    } else {
      toggled[to] = c != col;
      if (!dfs(to)) return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  in >> n >> m;
  edges.resize(n);
  color.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    char c;
    in >> a >> b >> c;
    --a;
    --b;
    edges[a].push_back(b);
    edges[b].push_back(a);
    color[a].push_back(c == 'R');
    color[b].push_back(c == 'R');
  }
  vector<int> answer[2];
  bool answer_found[2] = {true, true};
  for (col = 0; col < 2; ++col) {
    mark.assign(n, 0);
    toggled.assign(n, 0);
    for (int i = 0; i < n; ++i) {
      if (!mark[i]) {
        visited.clear();
        toggled[i] = 0;
        vector<int> cur1, cur2;
        bool found1 = false, found2 = false;
        if (dfs(i)) {
          found1 = true;
          for (int j = 0; j < visited.size(); ++j)
            if (toggled[visited[j]]) {
              cur1.push_back(visited[j]);
            }
        }
        for (int j = 0; j < visited.size(); ++j)
          toggled[visited[j]] = mark[visited[j]] = 0;
        visited.clear();
        toggled[i] = 1;
        if (dfs(i)) {
          found2 = 1;
          for (int j = 0; j < visited.size(); ++j)
            if (toggled[visited[j]]) {
              cur2.push_back(visited[j]);
            }
        }
        if (!found1 && !found2) {
          answer_found[col] = false;
          break;
        }
        if (found1 && (!found2 || cur1.size() < cur2.size()))
          answer[col].insert(answer[col].end(), begin(cur1), end(cur1));
        else
          answer[col].insert(answer[col].end(), begin(cur2), end(cur2));
      }
    }
  }
  if (!answer_found[0] && !answer_found[1])
    out << -1;
  else {
    vector<int> a;
    if (answer_found[0] &&
        (!answer_found[1] || answer[0].size() < answer[1].size()))
      a = answer[0];
    else
      a = answer[1];
    out << a.size() << "\n";
    for (int i = 0; i < a.size(); ++i) out << a[i] + 1 << " ";
  }
  return 0;
}
