#include <bits/stdc++.h>
using namespace std;
void home() {
  freopen("TEST.INP", "r", stdin);
  freopen("TEST.OUT", "w", stdout);
}
const int N = 1e5 + 1, mod = 1e9 + 7;
int n, m, dtplt;
char color;
vector<pair<int, int> > adj[N], dsk[N];
vector<int> tplt[N];
bool Free[N], change[N], recent[N];
struct answer {
  vector<int> tv;
  int changes;
} dp[N][2];
void enter() {
  scanf("%d%d", &(n), &(m));
  for (int i = 1; i <= (m); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    scanf(" %c", &color);
    if (color == 'B') {
      adj[u].push_back(make_pair(v, 0));
      adj[v].push_back(make_pair(u, 0));
    } else {
      adj[u].push_back(make_pair(v, 1));
      adj[v].push_back(make_pair(u, 1));
    }
  }
}
void Visit(int u) {
  tplt[dtplt].push_back(u);
  Free[u] = 1;
  for (int i = (0); i <= (((int)(adj[u]).size()) - 1); ++i) {
    int v = adj[u][i].first;
    if (!Free[v]) Visit(v);
  }
}
void init() {
  for (int i = 1; i <= (n); ++i)
    if (!Free[i]) {
      dtplt++;
      Visit(i);
    }
  for (int i = 1; i <= (n); ++i) dsk[i] = adj[i];
}
bool dfs(int u, bool is, int color) {
  Free[u] = 1;
  recent[u] = is;
  for (int i = (0); i <= (((int)(dsk[u]).size()) - 1); ++i) {
    int v = dsk[u][i].first, cl = dsk[u][i].second;
    if (!Free[v]) {
      if (is) cl = 1 - cl;
      if (!dfs(v, (cl != color), color)) return 0;
    } else {
      bool ischange = 1;
      if (is) cl = 1 - cl;
      if (cl == color) ischange = 0;
      if (ischange != recent[v]) return 0;
    }
  }
  return true;
}
bool cmp(answer u, answer v) { return u.changes < v.changes; }
answer sol(vector<int> &a, int color) {
  answer Count, ans;
  Count.changes = ans.changes = 0;
  memset((recent), 0, sizeof((recent)));
  memset((Free), 0, sizeof((Free)));
  bool ok = dfs(a[0], 1, color);
  if (ok)
    for (int i = (0); i <= (((int)(a).size()) - 1); ++i) {
      if (recent[a[i]]) Count.changes++, Count.tv.push_back(a[i]);
    }
  else
    Count.changes = mod;
  memset((recent), 0, sizeof((recent)));
  memset((Free), 0, sizeof((Free)));
  ok = dfs(a[0], 0, color);
  if (ok)
    for (int i = (0); i <= (((int)(a).size()) - 1); ++i) {
      if (recent[a[i]]) ans.changes++, ans.tv.push_back(a[i]);
    }
  else
    ans.changes = mod;
  return min(Count, ans, cmp);
}
long long cl_0 = 0, cl_1 = 0;
int main() {
  enter();
  init();
  for (int i = 1; i <= (dtplt); ++i)
    dp[i][0] = sol(tplt[i], 0), dp[i][1] = sol(tplt[i], 1);
  for (int i = 1; i <= (dtplt); ++i)
    cl_0 += dp[i][0].changes, cl_1 += dp[i][1].changes;
  if (min(cl_1, cl_0) >= mod) {
    cout << -1;
    return 0;
  }
  if (cl_0 < cl_1) {
    cout << cl_0 << endl;
    for (int i = 1; i <= (dtplt); ++i)
      for (int j = (0); j <= (((int)(dp[i][0].tv).size()) - 1); ++j)
        printf("%d ", (dp[i][0].tv[j]));
  } else {
    cout << cl_1 << endl;
    for (int i = 1; i <= (dtplt); ++i)
      for (int j = (0); j <= (((int)(dp[i][1].tv).size()) - 1); ++j)
        printf("%d ", (dp[i][1].tv[j]));
  }
  return 0;
}
