#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
vector<pair<int, int> > V[200005];
int n, m;
vector<int> RR[2], res;
int color[200005];
int que[200005], size;
bool cal(int id) {
  memset(color, -1, sizeof(color));
  RR[id].clear();
  for (int i = (1); i <= (n); ++i)
    if (color[i] == -1) {
      size = 0;
      que[size++] = i;
      int mau = 0;
      color[i] = 1;
      for (int t = 0; t < (size); ++t) {
        int u = que[t];
        mau += color[u];
        for (int j = 0; j < (((int)(V[u]).size())); ++j) {
          int v = V[u][j].first;
          int c = V[u][j].second;
          if (color[v] != -1) {
            if (color[u] ^ color[v] ^ id ^ c) {
              return 0;
            }
          } else {
            color[v] = color[u] ^ id ^ c;
            que[size++] = v;
          }
        }
      }
      for (int t = 0; t < (size); ++t) {
        int u = que[t];
        if (mau > size / 2) {
          if (!color[u]) RR[id].push_back(u);
        } else {
          if (color[u]) RR[id].push_back(u);
        }
      }
    }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int run = 0; run < (m); ++run) {
    int u, v;
    char ch;
    cin >> u >> v >> ch;
    int id = (ch == 'R' ? 1 : 0);
    V[u].push_back(make_pair(v, id));
    V[v].push_back(make_pair(u, id));
  }
  if (cal(0)) {
    if (cal(1)) {
      if (((int)(RR[0]).size()) < ((int)(RR[1]).size())) {
        res = RR[0];
      } else
        res = RR[1];
    } else
      res = RR[0];
  } else {
    if (cal(1))
      res = RR[1];
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ((int)(res).size()) << endl;
  for (int i = 0; i < (((int)(res).size())); ++i) cout << res[i] << " ";
  return 0;
}
