#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<pair<int, int> >* G;
int* color;
bool* visited;
int wantedColor;
vector<int> sol1;
vector<int> sol2;
vector<int> sol;
void reset() {
  sol.clear();
  for (int i = 0; i <= N; i++) {
    visited[i] = false;
    color[i] = -100;
  }
}
bool bfs(int x) {
  queue<pair<int, int> > q;
  vector<int> comp1;
  vector<int> comp2;
  pair<int, int> prvi;
  prvi.first = x;
  prvi.second = 0;
  q.push(prvi);
  color[x] = 0;
  while (!q.empty()) {
    pair<int, int> tmp = q.front();
    q.pop();
    if (visited[tmp.first]) continue;
    visited[tmp.first] = true;
    if (tmp.second == 0)
      comp1.push_back(tmp.first);
    else
      comp2.push_back(tmp.first);
    for (int i = 0; i < G[tmp.first].size(); i++) {
      int bojaZaSusjeda;
      if (wantedColor == G[tmp.first][i].second)
        bojaZaSusjeda = color[tmp.first];
      else
        bojaZaSusjeda = 1 - color[tmp.first];
      if (bojaZaSusjeda == (1 - color[G[tmp.first][i].first])) {
        return false;
      }
      if (!visited[G[tmp.first][i].first]) {
        pair<int, int> newNode;
        newNode.first = G[tmp.first][i].first;
        newNode.second = bojaZaSusjeda;
        color[newNode.first] = bojaZaSusjeda;
        q.push(newNode);
      }
    }
  }
  if (comp1.size() < comp2.size()) {
    for (int i = 0; i < comp1.size(); i++) sol.push_back(comp1[i]);
  } else {
    for (int i = 0; i < comp2.size(); i++) sol.push_back(comp2[i]);
  }
  return true;
}
bool go(int c) {
  reset();
  wantedColor = c;
  for (int i = 1; i <= N; i++) {
    if (!visited[i]) {
      if (!bfs(i)) {
        return false;
      }
    }
  }
  for (int i = 0; i < sol.size(); i++) {
    if (c == 1)
      sol1.push_back(sol[i]);
    else
      sol2.push_back(sol[i]);
  }
  return true;
}
int main() {
  scanf("%d %d", &N, &M);
  G = new vector<pair<int, int> >[N + 1];
  color = new int[N + 1];
  visited = new bool[N + 1];
  int a, b;
  char c;
  for (int i = 0; i < M; i++) {
    scanf("%d %d %c", &a, &b, &c);
    if (c == 'R') {
      G[a].push_back(make_pair(b, 1));
      G[b].push_back(make_pair(a, 1));
    } else {
      G[a].push_back(make_pair(b, 2));
      G[b].push_back(make_pair(a, 2));
    }
  }
  bool s1 = go(1);
  bool s2 = go(2);
  if (!s1 && !s2) {
    printf("-1");
    return 0;
  } else {
    if (!s1) {
      printf("%d\n", sol2.size());
      for (int i = 0; i < sol2.size(); i++) printf("%d ", sol2[i]);
    } else if (!s2) {
      printf("%d\n", sol1.size());
      for (int i = 0; i < sol1.size(); i++) printf("%d ", sol1[i]);
    } else {
      if (sol1.size() < sol2.size()) {
        printf("%d\n", sol1.size());
        for (int i = 0; i < sol1.size(); i++) printf("%d ", sol1[i]);
      } else {
        printf("%d\n", sol2.size());
        for (int i = 0; i < sol2.size(); i++) printf("%d ", sol2[i]);
      }
    }
  }
  return 0;
}
