#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, bool> > adj[100005];
int col[100005];
bool impo, toP0;
int c0, c1;
bool stC;
vector<int> toPaint;
void dfs(int x, bool xc, bool t) {
  if (impo) return;
  col[x] = xc;
  if (toP0 != xc) toPaint.push_back(x);
  if (xc == 0)
    c0++;
  else
    c1++;
  for (int i = 0; i < ((int)(adj[x]).size()); i++) {
    int son = adj[x][i].first;
    bool isRed = adj[x][i].second;
    bool same = t == isRed;
    if (col[son] == -1) {
      dfs(son, same ^ (xc == 0), t);
    } else {
      if (col[son] != (same ^ (xc == 0))) impo = true;
    }
  }
}
int main() {
  while (scanf("%d %d", &n, &m) == 2) {
    for (int i = 0; i < n; i++) adj[i].clear();
    for (int i = 0; i < m; i++) {
      int a, b;
      string c;
      cin >> a >> b >> c;
      a--;
      b--;
      adj[a].push_back(make_pair(b, c == "R"));
      adj[b].push_back(make_pair(a, c == "R"));
    }
    memset(col, -1, sizeof(col));
    impo = 0;
    vector<bool> toPaint0T;
    int sumT = 0;
    for (int i = 0; i < n; i++) {
      if (col[i] == -1) {
        c1 = 0;
        c0 = 0;
        dfs(i, 0, 1);
        toPaint0T.push_back(c1 > c0);
        sumT += min(c1, c0);
      }
    }
    bool impoT = impo;
    if (impoT) sumT = INT_MAX;
    memset(col, -1, sizeof(col));
    impo = 0;
    int sumF = 0;
    vector<bool> toPaint0F;
    for (int i = 0; i < n; i++) {
      if (col[i] == -1) {
        c1 = 0;
        c0 = 0;
        dfs(i, 0, 0);
        toPaint0F.push_back(c1 > c0);
        sumF += min(c1, c0);
      }
    }
    bool impoF = impo;
    if (impoF) sumF = INT_MAX;
    if (impoT && impoF)
      puts("-1");
    else {
      memset(col, -1, sizeof(col));
      int cnt = 0;
      impo = 0;
      toPaint.clear();
      for (int i = 0; i < n; i++) {
        if (col[i] == -1) {
          c1 = 0;
          c0 = 0;
          if (sumF < sumT)
            toP0 = toPaint0F[cnt++];
          else
            toP0 = toPaint0T[cnt++];
          dfs(i, 0, !(sumF < sumT));
        }
      }
      printf("%d\n", ((int)(toPaint).size()));
      for (int i = 0; i < ((int)(toPaint).size()); i++) {
        if (i != 0) {
          printf(" ");
        }
        printf("%d", (toPaint[i] + 1));
      }
      puts("");
    }
  }
}
