#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T poww(T b, T p) {
  long long a = 1;
  while (p) {
    if (p & 1) {
      a = (a * b);
    }
    p >>= 1;
    b = (b * b);
  }
  return a;
}
template <class T>
inline T gcd(T a, T b) {
  if (b > a) return gcd(b, a);
  return ((b == 0) ? a : gcd(b, a % b));
}
enum { red, blue };
vector<pair<int, int> > v[100002];
int done[100002], n;
typedef struct sets {
  std::vector<int> col[2];
} sets;
int dfs(int k, const int col, sets& sts, int st = 0) {
  if (done[k] != -1) {
    if (done[k] != st) return 1;
    return 0;
  }
  done[k] = st;
  sts.col[st].push_back(k);
  int j, kk;
  for ((j) = 0; (j) < (v[k].size()); (j)++) {
    kk = v[k][j].second;
    kk = dfs(v[k][j].first, col, sts, (kk == col ? st : !st));
    if (kk) return 1;
  }
  return 0;
}
int paint(int col, std::vector<sets>& v) {
  int i, j, k;
  for ((i) = 0; (i) < (n); (i)++) done[i] = -1;
  int fail = 0;
  for ((i) = 0; (i) < (n); (i)++) {
    if (done[i] == -1) {
      v.push_back(sets());
      fail |= dfs(i, col, v.back());
    }
  }
  return fail;
}
int main() {
  register int i, j, k, col;
  int m;
  scanf("%d%d", &n, &m);
  char s[5];
  for ((i) = 0; (i) < (m); (i)++) {
    scanf("%d%d%s", &j, &k, s);
    j--, k--;
    col = (s[0] == 'R' ? red : blue);
    v[j].push_back(make_pair(k, col));
    v[k].push_back(make_pair(j, col));
  }
  vector<sets> str, stb;
  int failr = 1, failb = 1, fail = 1;
  failr = paint(red, str);
  failb = paint(blue, stb);
  fail = failr & failb;
  if (fail) {
    cout << "-1\n";
  } else {
    int cr = 0, cb = 0;
    if (!failr)
      for ((i) = 0; (i) < (str.size()); (i)++) {
        cr += min(str[i].col[0].size(), str[i].col[1].size());
      }
    if (!failb)
      for ((i) = 0; (i) < (stb.size()); (i)++) {
        cb += min(stb[i].col[0].size(), stb[i].col[1].size());
      }
    else
      cb = n + 1;
    if (cb < cr || failr) swap(cr, cb), swap(str, stb);
    cout << cr << "\n";
    for ((i) = 0; (i) < (str.size()); (i)++) {
      k = (str[i].col[0].size() < str[i].col[1].size() ? 0 : 1);
      for ((j) = 0; (j) < (str[i].col[k].size()); (j)++)
        printf("%d ", str[i].col[k][j] + 1);
    }
  }
  cout << "\n";
}
