#include <bits/stdc++.h>
using namespace std;
int col[100005];
int n;
vector<int> g[2][100005];
int call;
vector<int> V;
int solve(int i, int c) {
  if (col[i] != -1) {
    if (col[i] == c)
      return 0;
    else
      return 10000000;
  }
  col[i] = c;
  V.push_back(i);
  int res = c;
  for (int j = 0; j < g[call][i].size(); j++) {
    int u = g[call][i][j];
    res += solve(u, c);
    if (res > n) return res;
  }
  for (int j = 0; j < g[1 - call][i].size(); j++) {
    int res2 = solve(g[1 - call][i][j], 1 - c);
    if (res2 > 1000000) return res2;
    res += res2;
  }
  return res;
}
vector<int> choose;
int solve() {
  memset(col, -1, sizeof(col));
  int ans = 0;
  call = 0;
  vector<int> moves;
  for (int i = 0; i < n; i++) {
    if (col[i] != -1) continue;
    V.clear();
    int res = solve(i, 0);
    int all = V.size();
    if (res > n) {
      ans = 1000000000;
      break;
    }
    if (res > all - res) {
      ans += all - res;
      for (int j = 0; j < V.size(); j++)
        if (col[V[j]] == 0) moves.push_back(V[j]);
    } else {
      ans += res;
      for (int j = 0; j < V.size(); j++)
        if (col[V[j]] == 1) moves.push_back(V[j]);
    }
  }
  memset(col, -1, sizeof(col));
  vector<int> moves2;
  int ans2 = 0;
  call = 1;
  for (int i = 0; i < n; i++) {
    if (col[i] != -1) continue;
    V.clear();
    int res = solve(i, 0);
    if (res > n) {
      ans2 = 1000000000;
      break;
    }
    int all = V.size();
    if (res > all - res) {
      ans2 += all - res;
      for (int j = 0; j < V.size(); j++)
        if (col[V[j]] == 0) moves2.push_back(V[j]);
    } else {
      ans2 += res;
      for (int j = 0; j < V.size(); j++)
        if (col[V[j]] == 1) moves2.push_back(V[j]);
    }
  }
  if (ans < ans2)
    choose = moves;
  else
    choose = moves2;
  return min(ans, ans2);
}
char s[10];
int main() {
  int m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d %s", &u, &v, s);
    u--;
    v--;
    if (s[0] == 'R') {
      g[0][u].push_back(v);
      g[0][v].push_back(u);
    } else {
      g[1][u].push_back(v);
      g[1][v].push_back(u);
    }
  }
  int ans = solve();
  if (ans > n)
    printf("-1\n");
  else {
    printf("%d\n", ans);
    for (int i = 0; i < choose.size(); i++) printf("%d ", choose[i] + 1);
    printf("\n");
  }
}
