#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
int n, m;
vector<vector<int> > g;
int a[N], b[N], comp[N], cmp, ans[N];
char clr[N];
char vis[N];
bool isD[N];
int B, W;
bool DFS(int u, bool clr) {
  if (vis[u] != -1) return clr == vis[u];
  comp[u] = cmp;
  vis[u] = clr;
  if (!isD[u]) {
    B += clr;
    W += !clr;
  }
  for (int i = 0; i < g[u].size(); ++i)
    if (!DFS(g[u][i], !clr)) return false;
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d %c", &a[i], &b[i], &clr[i]);
    --a[i];
    --b[i];
    clr[i] = clr[i] == 'R';
  }
  int res = 1e9;
  vector<int> sol;
  for (int it = 0; it < 2; ++it) {
    memset(vis, -1, sizeof(vis));
    memset(isD, 0, sizeof(isD));
    g.clear();
    g.resize(n);
    for (int i = 0; i < m; ++i) {
      clr[i] = !clr[i];
      if (clr[i]) {
        int x = g.size();
        g.push_back(vector<int>());
        isD[x] = true;
        g[a[i]].push_back(x);
        g[x].push_back(a[i]);
        g[b[i]].push_back(x);
        g[x].push_back(b[i]);
      } else {
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
      }
    }
    int cur = 0;
    cmp = 0;
    for (int i = 0; i < g.size(); ++i)
      if (vis[i] == -1) {
        B = W = 0;
        if (!DFS(i, 0)) {
          cur = 1e9;
          break;
        }
        cur += min(B, W);
        ans[cmp] = B <= W;
        ++cmp;
      }
    if (res > cur) {
      res = cur;
      sol.clear();
      for (int i = 0; i < n; ++i)
        if (vis[i] == ans[comp[i]]) sol.push_back(i);
      assert(sol.size() == res);
    }
  }
  if (res > 1e8) res = -1;
  printf("%d\n", res);
  if (res != -1) {
    for (int i = 0; i < sol.size(); ++i)
      printf("%s%d", i ? " " : "", sol[i] + 1);
    puts("");
  }
  return 0;
}
