#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
int sgn(T x) {
  return x > 0 ? 1 : (x < 0 ? -1 : 0);
}
const long double pi = acos(-1.0);
const int N = 100100;
int n;
int m;
vector<int> v[N];
vector<int> w[N];
vector<int> vert[N];
int was[N];
int col[N];
int cnt[N];
int ea[N];
int eb[N];
int ec[N];
int p[2];
vector<int> q[2];
int bip[N];
int go(int x, int r) {
  if (was[x]) return 0;
  was[x] = 1;
  col[x] = r;
  cnt[r]++;
  vert[r].push_back(x);
  for (int i = 0; i < ((int)(v[x]).size()); i++) go(v[x][i], r);
  return 0;
}
int go2(int x, int c) {
  if (was[x]) return int(bip[x] != c);
  bip[x] = c;
  was[x] = 1;
  p[c] += cnt[x];
  q[c].push_back(x);
  for (int i = 0; i < ((int)(w[x]).size()); i++)
    if (go2(w[x][i], c ^ 1)) return 1;
  return 0;
}
pair<int, vector<int> > calc(int c) {
  memset(was, 0, sizeof(was));
  for (int i = 0; i < n; i++) v[i].clear();
  for (int i = 0; i < m; i++)
    if (ec[i] == c) {
      v[ea[i]].push_back(eb[i]);
      v[eb[i]].push_back(ea[i]);
    }
  int r = 0;
  for (int i = 0; i < n; i++)
    if (!was[i]) {
      vert[r].clear();
      cnt[r] = 0;
      go(i, r);
      w[r].clear();
      r++;
    }
  vector<int> ans;
  for (int i = 0; i < m; i++)
    if (ec[i] != c) {
      int a = col[ea[i]];
      int b = col[eb[i]];
      if (a == b) return make_pair(1e9, ans);
      w[a].push_back(b);
      w[b].push_back(a);
    }
  memset(was, 0, sizeof(was));
  for (int i = 0; i < r; i++)
    if (!was[i]) {
      p[0] = p[1] = 0;
      q[0].clear();
      q[1].clear();
      if (go2(i, 0)) return make_pair(1e9, ans);
      int t = p[0] < p[1] ? 0 : 1;
      for (int j = 0; j < ((int)(q[t]).size()); j++)
        for (int k = 0; k < ((int)(vert[q[t][j]]).size()); k++)
          ans.push_back(vert[q[t][j]][k]);
    }
  return make_pair(((int)(ans).size()), ans);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    char h[5];
    scanf("%d%d %s", &ea[i], &eb[i], h);
    ea[i]--;
    eb[i]--;
    ec[i] = int(h[0] == 'B');
  }
  pair<int, vector<int> > ans = min(calc(0), calc(1));
  if (ans.first > 1e8)
    printf("-1\n");
  else {
    sort((ans.second).begin(), (ans.second).end());
    printf("%d\n", ans.first);
    for (int i = 0; i < ans.first; i++) printf("%d ", ans.second[i] + 1);
    printf("\n");
  }
  return 0;
}
