#include <bits/stdc++.h>
using namespace std;
const int maxN(1e5 + 10);
typedef int i_N[maxN];
int N, M;
namespace graph {
i_N P, mark;
vector<int> adj[maxN];
pair<pair<int, int>, int> edge[maxN];
void link(const int u, const int id) { adj[u].push_back(id); }
int adj_node(const int u, const pair<int, int> &E) {
  return u == E.first ? E.second : E.first;
}
int bfs(const int sample, const int is_print) {
  queue<int> bfs_node;
  memset(P, 0, sizeof(P));
  int res(0);
  for (int u = 1; u <= N; u++)
    if (!P[u]) {
      vector<int> tmp;
      P[u] = -1;
      mark[u] = 0;
      bfs_node.push(u);
      int C(0), C1(0);
      while (!bfs_node.empty()) {
        const int u(bfs_node.front());
        bfs_node.pop();
        tmp.push_back(u);
        C++;
        C1 += mark[u];
        for (int i = 0; i < (int)adj[u].size(); i++) {
          const int id(adj[u][i]);
          const int v(adj_node(u, edge[id].first)), color(edge[id].second),
              t((color != sample) ^ mark[u]);
          if (!P[v]) {
            P[v] = u;
            mark[v] = t;
            bfs_node.push(v);
          } else if (mark[v] != t) {
            if (is_print) cout << -1;
            return 2e9;
          }
        }
      }
      res += min(C1, C - C1);
      if (C1 > C - C1)
        for (int i = 0; i < (int)tmp.size(); i++)
          mark[tmp[i]] = 1 - mark[tmp[i]];
    }
  if (is_print) {
    cout << res << '\n';
    for (int u = 1; u <= N; u++)
      if (mark[u]) cout << u << ' ';
  }
  return res;
}
}  // namespace graph
int main() {
  {
    using namespace graph;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
      char ch;
      cin >> edge[i].first.first >> edge[i].first.second >> ch;
      edge[i].second = ch == 'R';
      link(edge[i].first.first, i);
      link(edge[i].first.second, i);
    }
  }
  {
    using namespace graph;
    if (bfs(0, 0) < bfs(1, 0))
      bfs(0, 1);
    else
      bfs(1, 1);
  }
}
