#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct Edge {
  int v, col, next;
} E[maxn << 1];
int head[maxn], tol;
int vis[maxn], top, n, m;
vector<int> g[2], st[2];
void init() {
  memset(head, -1, sizeof head);
  tol = 0;
}
void add_edge(int u, int v, int col) {
  E[tol].v = v;
  E[tol].col = col;
  E[tol].next = head[u];
  head[u] = tol++;
}
bool dfs(int u, int f, int col) {
  vis[u] = f;
  st[f].push_back(u);
  for (int i = head[u]; ~i; i = E[i].next) {
    int v = E[i].v;
    if (vis[v] != -1) {
      if ((vis[u] ^ vis[v]) != (col ^ E[i].col)) return false;
      continue;
    }
    if (!dfs(v, col ^ E[i].col ^ vis[u], col)) return false;
  }
  return true;
}
int solve(int col) {
  memset(vis, -1, sizeof vis);
  for (int i = 1; i <= n; i++) {
    if (vis[i] == -1) {
      st[0].clear();
      st[1].clear();
      if (!dfs(i, 0, col)) {
        return n + 1;
      }
      int tmp = st[0].size() < st[1].size() ? 0 : 1;
      g[col].insert(g[col].end(), st[tmp].begin(), st[tmp].end());
    }
  }
  return g[col].size();
}
int main() {
  int u, v;
  char col;
  scanf("%d%d", &n, &m);
  init();
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %c", &u, &v, &col);
    add_edge(u, v, col == 'R' ? 1 : 0);
    add_edge(v, u, col == 'R' ? 1 : 0);
  }
  int sz0 = solve(0);
  int sz1 = solve(1);
  if (sz0 == n + 1 && sz1 == n + 1) {
    puts("-1");
    return 0;
  }
  int tmp = sz0 < sz1 ? 0 : 1;
  printf("%d\n", g[tmp].size());
  for (int i = 0; i < g[tmp].size(); i++) {
    printf("%d ", g[tmp][i]);
  }
  return 0;
}
