#include <bits/stdc++.h>
const int N = 100001;
const int inf = 0x3f3f3f3f;
using namespace std;
vector<pair<int, int> > g[N];
bool vis[4][N], used[N];
int f[2][N], s[4][N];
int dfs(int x, int sw, int k) {
  s[k][x] = sw;
  vis[k][x] = true;
  int i, v, c, p, tot = sw;
  for (i = 0; i < g[x].size(); i++) {
    v = g[x][i].first;
    c = g[x][i].second;
    if (vis[k][v]) {
      if ((s[k][v] ^ sw ^ c) != (k >> 1)) return -1;
    } else {
      p = dfs(v, c ^ sw ^ (k >> 1), k);
      if (p == -1) return -1;
      tot += p;
    }
  }
  return tot;
}
void dfs2(int x, int sw, int k) {
  used[x] = true;
  if (sw) printf("%d ", x + 1);
  int i, v, c;
  for (i = 0; i < g[x].size(); i++) {
    v = g[x][i].first;
    c = g[x][i].second;
    if (!used[v]) dfs2(v, sw ^ c ^ k, k);
  }
}
int main() {
  int n, m;
  int i, j, k, u, v, col;
  char c;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d %c", &u, &v, &c);
    u--;
    v--;
    if (c == 'B')
      col = 0;
    else
      col = 1;
    g[u].push_back(make_pair(v, col));
    g[v].push_back(make_pair(u, col));
  }
  int ans = inf, ansk;
  memset(vis, false, sizeof(vis));
  for (k = 0; k <= 1; k++) {
    int tot = 0, p = 0, q = 0;
    for (i = 0; i < n; i++)
      if (!vis[(k << 1)][i]) {
        p = dfs(i, 0, k << 1);
        q = dfs(i, 1, (k << 1) | 1);
        if (p == -1 && q == -1) {
          tot = inf;
          break;
        } else if (p == -1) {
          tot += q;
          f[k][i] = 1;
        } else if (q == -1) {
          tot += p;
          f[k][i] = 0;
        } else if (p < q) {
          tot += p;
          f[k][i] = 0;
        } else {
          tot += q;
          f[k][i] = 1;
        }
      }
    if (tot < ans) {
      ans = tot;
      ansk = k;
    }
  }
  if (ans == inf)
    printf("-1\n");
  else {
    memset(used, false, sizeof(used));
    printf("%d\n", ans);
    for (i = 0; i < n; i++)
      if (!used[i]) dfs2(i, f[ansk][i], ansk);
  }
  return 0;
}
