#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<pair<int, int> > G[N];
vector<int> com;
bool vis[N];
int U, V;
void dfs1(int u) {
  com.push_back(u);
  vis[u] = true;
  for (auto &x : G[u]) {
    if (x.second) {
      U = u;
      V = x.first;
    }
    if (vis[x.first]) continue;
    dfs1(x.first);
  }
}
int col[N];
int dfs2(int u) {
  vis[u] = true;
  int ret = 0;
  for (auto &x : G[u]) {
    if (vis[x.first]) {
      if (col[u] ^ col[x.first] ^ x.second) return 0x3f3f3f3f;
    } else {
      col[x.first] = col[u] ^ x.second;
      ret += col[x.first] + dfs2(x.first);
      if (ret >= 0x3f3f3f3f) return 0x3f3f3f3f;
    }
  }
  return ret;
}
vector<int> solve(int n) {
  vector<int> ret;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; ++i) {
    if (vis[i]) continue;
    U = V = -1;
    com.clear();
    dfs1(i);
    if (U == -1) continue;
    vector<int> a, b;
    for (auto x : com) vis[x] = false;
    col[U] = 1;
    int A = dfs2(U);
    for (auto x : com) {
      vis[x] = false;
      if (col[x]) a.push_back(x);
    }
    col[V] = 1;
    int B = dfs2(V);
    for (auto x : com) {
      if (col[x]) b.push_back(x);
    }
    if (A >= 0x3f3f3f3f && B >= 0x3f3f3f3f) {
      return vector<int>{-1};
    }
    if (A > B) swap(a, b);
    for (auto x : a) ret.push_back(x);
  }
  return ret;
}
inline bool bad(vector<int> &a) { return (int)a.size() == 1 && a[0] == -1; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int u, v, i = 0; i < m; ++i) {
    char s[2];
    scanf("%d%d%s", &u, &v, s);
    int c = *s == 'R';
    G[u].push_back(make_pair(v, c));
    G[v].push_back(make_pair(u, c));
  }
  vector<int> A = solve(n);
  for (int i = 1; i <= n; ++i) {
    for (auto &x : G[i]) {
      x.second ^= 1;
    }
  }
  vector<int> B = solve(n);
  if (bad(A) && bad(B)) {
    puts("-1");
    return 0;
  }
  if (bad(A) || (!bad(B) && B.size() < A.size())) {
    swap(A, B);
  }
  printf("%d\n", A.size());
  for (auto x : A) printf("%d ", x);
  return 0;
}
