#include <bits/stdc++.h>
using namespace std;
queue<int> q;
int to[2 * 100010], nxt[2 * 100010], col[2 * 100010];
int head[100010], edge;
int vst[100010], cpy[100010], prevst[100010];
int vis[100010];
int a[100010], N, ans;
void add(int u, int v, int c) {
  to[edge] = v;
  nxt[edge] = head[u];
  col[edge] = c;
  head[u] = edge++;
  to[edge] = u;
  nxt[edge] = head[v];
  col[edge] = c;
  head[v] = edge++;
  return;
}
void calc(int tp) {
  for (int i = (0); i < (N); i++) prevst[i] = vst[i];
  int u, t;
  memset(vst, 0xff, sizeof(vst));
  int res = 0;
  for (int i = (0); i < (N); i++) {
    if (vst[i] != -1) continue;
    int mx = 10000000;
    int j = 0;
    int hop = 0;
    q = queue<int>();
    q.push(i);
    q.push(j);
    vst[i] = j;
    bool ok = false;
    int cc = 0;
    while (!q.empty()) {
      u = q.front();
      q.pop();
      t = q.front();
      q.pop();
      a[cc++] = u;
      hop += t;
      for (int ID = head[u]; ID != -1; ID = nxt[ID]) {
        int v = to[ID];
        int c = col[ID];
        if (vst[v] == -1) {
          if ((t == 0 && c == tp) || (t == 1 && c != tp)) {
            q.push(v);
            q.push(0);
            vst[v] = 0;
          } else {
            q.push(v);
            q.push(1);
            vst[v] = 1;
          }
        } else {
          if (t == 0) {
            if (vst[v] == 1 && c == tp) ok = true;
            if (vst[v] == 0 && c != tp) ok = true;
          } else {
            if (vst[v] == 1 && c != tp) ok = true;
            if (vst[v] == 0 && c == tp) ok = true;
          }
          if (ok) break;
        }
      }
      if (ok) break;
    }
    if (!ok) {
      if (mx > hop) {
        mx = hop;
        for (int k = (0); k < (cc); k++) cpy[a[k]] = vst[a[k]];
      }
      if (mx > cc - hop) {
        mx = cc - hop;
        for (int k = (0); k < (cc); k++) cpy[a[k]] = 1 - vst[a[k]];
      }
    } else
      return;
    res += mx;
  }
  if (ans > res) {
    ans = res;
    for (int i = (0); i < (N); i++) vis[i] = cpy[i];
  }
  return;
}
int main() {
  int M, u, v;
  char ch;
  scanf("%d%d", &N, &M);
  memset(head, 0xff, sizeof(head));
  edge = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = (0); i < (M); i++) {
    scanf("%d%d %c", &u, &v, &ch);
    u--;
    v--;
    if (ch == 'R')
      add(u, v, 0);
    else
      add(u, v, 1);
  }
  ans = 10000000;
  calc(0);
  calc(1);
  if (ans == 10000000)
    puts("-1");
  else {
    printf("%d\n", ans);
    int ct = 0;
    for (int i = (0); i < (N); i++) {
      if (!vis[i]) continue;
      ct++;
      if (ct == ans)
        printf("%d\n", i + 1);
      else
        printf("%d ", i + 1);
    }
  }
  return 0;
}
