#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T1, class T2>
inline void print(T1 x1, T2 x2) {
  printsp(x1), println(x2);
}
template <class T1, class T2, class T3>
inline void print(T1 x1, T2 x2, T3 x3) {
  printsp(x1), printsp(x2), println(x3);
}
template <class T1, class T2, class T3, class T4>
inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {
  printsp(x1), printsp(x2), printsp(x3), println(x4);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
vector<pair<int, int> > adj[100111];
vector<int> res;
vector<int> tmp;
int ans = 0x3f3f3f3f;
int vst[100111];
vector<int> vec[2];
int n, m;
int col[100111];
int dfs(int u, int c, int k) {
  vec[c].push_back(u);
  vst[u] = 1;
  col[u] = c;
  for (int i = 0; i < ((int)adj[u].size()); i++) {
    int v = adj[u][i].first;
    if (adj[u][i].second == k) {
      if (vst[v]) {
        if (col[v] != c) return 0;
        continue;
      }
      if (dfs(v, c, k) == 0) return 0;
    } else {
      if (vst[v]) {
        if (col[v] != 1 - c) return 0;
        continue;
      }
      if (dfs(v, 1 - c, k) == 0) return 0;
    }
  }
  return 1;
}
int solve(int k) {
  memset(vst, 0, sizeof vst);
  tmp.clear();
  for (int i = 1; i <= n; i++)
    if (vst[i] == 0) {
      vec[0].clear();
      vec[1].clear();
      if (dfs(i, 0, k) == 0) return 0;
      if (((int)vec[0].size()) < ((int)vec[1].size())) swap(vec[0], vec[1]);
      for (int j = 0; j < ((int)vec[1].size()); j++) tmp.push_back(vec[1][j]);
    }
  return 1;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    gn(u, v);
    char c;
    scanf(" %c ", &c);
    adj[u].push_back(pair<int, int>(v, c == 'R'));
    adj[v].push_back(pair<int, int>(u, c == 'R'));
  }
  if (solve(0)) res = tmp, smin(ans, ((int)tmp.size()));
  if (solve(1) and ((int)tmp.size()) < ans) {
    res = tmp;
    ans = ((int)tmp.size());
  }
  if (ans == 0x3f3f3f3f) return puts("-1");
  sort(res.begin(), res.end());
  cout << ((int)res.size()) << endl;
  for (int i = 0; i < ((int)res.size()); i++) {
    println(res[i]);
  }
  return 0;
}
