#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
  x = 0;
  long long f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  x *= f;
  return;
}
long long fs(long long x) { return x < 0 ? -x : x; }
void print(long long x) {
  if (x < 10) {
    putchar(x + '0');
    return;
  }
  print(x / 10);
  putchar(x % 10 + '0');
  return;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = fs(x);
  }
  print(x);
  return;
}
long long mint(long long x, long long y) { return x < y ? x : y; }
long long maxt(long long x, long long y) { return x > y ? x : y; }
struct node {
  long long v;
  bool e;
  node(long long V, long long E) { v = V, e = E; }
};
vector<node> G[100005];
vector<long long> v1, v0, v2, v;
long long n, m, col, ans = 0x3f3f3f3f;
bool vis[100005], c[100005], fl;
void dfs(long long u, bool p) {
  c[u] = p;
  vis[u] = 1;
  if (p == 1)
    v1.push_back(u);
  else
    v0.push_back(u);
  for (int i = 0; i < G[u].size(); i++) {
    long long v = G[u][i].v;
    long long e = G[u][i].e;
    if (!vis[v])
      dfs(v, e ^ p ^ col);
    else if (c[u] ^ c[v] ^ e != col) {
      fl = 1;
      return;
    }
  }
}
int main() {
  read(n), read(m);
  for (int i = 1; i <= m; i++) {
    long long u, v;
    read(u), read(v);
    char c = getchar();
    bool f;
    if (c == 'R')
      f = 1;
    else
      f = 0;
    G[u].push_back(node(v, f));
    G[v].push_back(node(u, f));
  }
  for (col = 0; col <= 1; col++) {
    v2.clear();
    memset(vis, 0, sizeof(vis));
    memset(c, 0, sizeof(c));
    long long tmp = 0;
    fl = 0;
    for (int i = 1; i <= n; i++)
      if (!vis[i]) {
        v1.clear();
        v0.clear();
        dfs(i, 1);
        if (fl) break;
        tmp += mint(v1.size(), v0.size());
        if (v1.size() > v0.size())
          for (int j = 0; j < v0.size(); j++) v2.push_back(v0[j]);
        else
          for (int j = 0; j < v1.size(); j++) v2.push_back(v1[j]);
      }
    if (fl) continue;
    if (ans > tmp) {
      ans = tmp;
      v = v2;
    }
  }
  if (ans == 0x3f3f3f3f)
    puts("-1");
  else {
    printf("%lld\n", ans);
    for (int i = 0; i < v.size(); i++) printf("%lld ", v[i]);
  }
}
