#include <bits/stdc++.h>
using namespace std;
struct type_edge {
  int u, v;
  bool c;
  type_edge() {}
  type_edge(int a, int b, bool d) {
    u = a;
    v = b;
    c = d;
  }
} edge[100005];
vector<int> G[200005];
int vis[200005], cnt, n;
int comp[200005], used[200005];
int dfs(int v, int mark) {
  vis[v] = mark;
  int ret = 0;
  for (int x : G[v])
    if (!vis[x]) ret += dfs(x, mark);
  return ret + (v <= n ? 1 : 0);
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    char c;
    scanf("%d%d %c", &a, &b, &c);
    edge[i] = type_edge(a, b, (c == 'B'));
  }
  vector<int> ans;
  bool has_ans = 0;
  for (int color = 1; color >= 0; color--) {
    for (int i = 1; i <= 2 * n; i++) {
      G[i].clear();
      vis[i] = 0;
      comp[i] = 0;
      used[i] = 0;
    }
    for (int i = 0; i < m; i++) {
      int f = edge[i].u, s = edge[i].v;
      if (edge[i].c == color) {
        G[f].push_back(s);
        G[s].push_back(f);
        G[s + n].push_back(f + n);
        G[f + n].push_back(s + n);
      } else {
        G[f].push_back(s + n);
        G[s + n].push_back(f);
        G[s].push_back(f + n);
        G[f + n].push_back(s);
      }
    }
    cnt = 1;
    bool fail = 0;
    for (int i = 1; i <= 2 * n; i++) {
      if (!vis[i]) {
        comp[cnt] = dfs(i, cnt);
        cnt++;
      }
    }
    set<int> comp_used;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == vis[i + n]) {
        fail = 1;
        break;
      }
      if (used[vis[i]] || used[vis[i + n]]) {
        assert(used[vis[i]] & used[vis[i + n]]);
        continue;
      }
      used[vis[i]] = used[vis[i + n]] = 1;
      if (comp[vis[i]] < comp[vis[i + n]])
        comp_used.insert(vis[i]);
      else
        comp_used.insert(vis[i + n]);
    }
    if (fail) continue;
    vector<int> aux;
    for (int i = 1; i <= n; i++) {
      if (comp_used.find(vis[i]) != comp_used.end()) aux.push_back(i);
    }
    if (color == 1)
      ans = aux;
    else if (aux.size() < ans.size() || !has_ans)
      ans = aux;
    has_ans = 1;
  }
  if (has_ans == 0)
    printf("-1\n");
  else {
    printf("%d\n", ans.size());
    for (int x : ans) printf("%d ", x);
    printf("\n");
  }
  return 0;
}
