#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
const int maxm = 3 * maxn;
vector<pair<int, int> > G[maxn];
vector<int> mp[maxn];
int ans;
struct Edge {
  int to, next;
} e[maxm];
int head[maxn], tot;
void init() {
  tot = 0;
  memset(head, -1, sizeof(head));
}
void addedge(int from, int to) {
  e[tot].to = to;
  e[tot].next = head[from];
  head[from] = tot++;
}
int Low[maxn], DFN[maxn], Stack[maxn], Belong[maxn], num[maxn];
int Index, top, scc;
bool Instack[maxn];
int flag[maxn], vis[maxn];
void Tarjan(int u, int n) {
  int v;
  Low[u] = DFN[u] = ++Index;
  Stack[top++] = u;
  Instack[u] = true;
  for (int i = head[u]; i != -1; i = e[i].next) {
    v = e[i].to;
    if (!DFN[v]) {
      Tarjan(v, n);
      if (Low[u] > Low[v]) Low[u] = Low[v];
    } else if (Instack[v] && Low[u] > DFN[v])
      Low[u] = DFN[v];
  }
  if (Low[u] == DFN[u]) {
    scc++;
    do {
      v = Stack[--top];
      Instack[v] = false;
      Belong[v] = scc;
      if (v <= n) num[scc]++;
      mp[scc].push_back(v);
    } while (v != u);
  }
}
void solve(int n, int C) {
  for (int i = 0; i < 2 * n; i++) mp[i].clear();
  init();
  memset(DFN, 0, sizeof(DFN));
  memset(Instack, 0, sizeof(Instack));
  memset(flag, 0, sizeof(flag));
  memset(num, 0, sizeof(num));
  if (C == 1) {
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < G[i].size(); j++) {
        int u = i, v = G[i][j].first, w = G[i][j].second;
        if (w == 1) {
          addedge(u, v);
          addedge(v, u);
          addedge(u + n, v + n);
          addedge(v + n, u + n);
        } else {
          addedge(u, v + n);
          addedge(v, u + n);
          addedge(u + n, v);
          addedge(v + n, u);
        }
      }
    }
  } else {
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < G[i].size(); j++) {
        int u = i, v = G[i][j].first, w = G[i][j].second;
        if (w == 2) {
          addedge(u, v);
          addedge(v, u);
          addedge(u + n, v + n);
          addedge(v + n, u + n);
        } else {
          addedge(u, v + n);
          addedge(v, u + n);
          addedge(u + n, v);
          addedge(v + n, u);
        }
      }
    }
  }
  Index = scc = top = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (!DFN[i]) Tarjan(i, n);
  }
  for (int i = 1; i <= n; i++) {
    if (Belong[i] == Belong[i + n]) return;
  }
  int ANS = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (flag[i] != 0) continue;
    if (num[Belong[i]] <= num[Belong[i + n]]) {
      ANS += num[Belong[i]];
      for (int j = 0; j < mp[Belong[i]].size(); j++) {
        int cnt = mp[Belong[i]][j];
        if (cnt <= n) {
          flag[cnt] = 1;
          flag[cnt + n] = 2;
        } else {
          flag[cnt] = 1;
          flag[cnt - n] = 2;
        }
      }
    } else {
      ANS += num[Belong[i + n]];
      for (int j = 0; j < mp[Belong[i + n]].size(); j++) {
        int cnt = mp[Belong[i + n]][j];
        if (cnt <= n) {
          flag[cnt] = 1;
          flag[cnt + n] = 2;
        } else {
          flag[cnt] = 1;
          flag[cnt - n] = 2;
        }
      }
    }
  }
  if (ANS < ans) {
    memset(vis, 0, sizeof(vis));
    ans = ANS;
    for (int i = 1; i <= 2 * n; i++)
      if (flag[i] == 1) vis[i] = 1;
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int u, v;
  char s[2];
  for (int i = 0; i < m; i++) {
    scanf("%d%d%s", &u, &v, s);
    if (s[0] == 'B')
      G[u].push_back(pair<int, int>{v, 1});
    else
      G[u].push_back(pair<int, int>{v, 2});
  }
  ans = 0x3f3f3f3f;
  solve(n, 1);
  solve(n, 2);
  if (ans == 0x3f3f3f3f)
    puts("-1");
  else {
    printf("%d\n", ans);
    for (int i = 1; i <= n; i++)
      if (vis[i] == 1) printf("%d ", i);
    printf("\n");
  }
}
