#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, mod = 1e9 + 9;
const int maxn = 100010;
const long double eps = 1e-5;
const int EPS = 500 * 500;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long first = 1;
  while (!isdigit(ch)) {
    if (ch == '-') first *= -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= first;
}
template <typename T, typename... Args>
void read(T &first, Args &...args) {
  read(first);
  read(args...);
}
int n, m, tag, now, block;
int sum[2];
vector<pair<int, int>> G[maxn];
vector<int> ans[10], res[maxn][2];
int tim[maxn];
bool vis[maxn][10];
inline bool dfs(int u, int fa, int Xor) {
  if (vis[u][now]) return 1;
  tim[u] = Xor ^ tim[fa];
  if (tim[u]) ans[now].push_back(u);
  vis[u][now] = 1;
  for (auto it : G[u]) {
    int v = it.first;
    int c = it.second;
    if (vis[v][now]) {
      if ((tim[v] ^ tim[u]) != (tag ^ c)) return 0;
      continue;
    }
    if (!dfs(v, u, tag ^ c)) return 0;
  }
  return 1;
}
inline void slove() {
  int idx = 0;
  for (int i = 1; i <= n; ++i) {
    if (vis[i][tag << 1]) continue;
    ans[tag << 1].clear();
    ans[tag << 1 | 1].clear();
    bool flag1 = 1, flag2 = 1;
    now = tag << 1;
    tim[i] = 0;
    vis[i][now] = 1;
    for (auto it : G[i]) {
      int v = it.first;
      int c = it.second;
      if (!dfs(v, i, c ^ tag)) {
        flag1 = 0;
        break;
      }
    }
    now = tag << 1 | 1;
    tim[i] = 1;
    vis[i][now] = 1;
    ans[now].push_back(i);
    for (auto it : G[i]) {
      int v = it.first;
      int c = it.second;
      if (!dfs(v, i, c ^ tag)) {
        flag2 = 0;
        break;
      }
    }
    if (flag1 && flag2) {
      if (ans[tag << 1].size() < ans[tag << 1 | 1].size())
        res[idx++][tag] = ans[tag << 1];
      else
        res[idx++][tag] = ans[tag << 1 | 1];
    } else if (flag1)
      res[idx++][tag] = ans[tag << 1];
    else if (flag2)
      res[idx++][tag] = ans[tag << 1 | 1];
    else {
      sum[tag] = 0x3f3f3f3f;
      return;
    }
    ans[tag << 1].clear();
    ans[tag << 1 | 1].clear();
    sum[tag] += res[idx - 1][tag].size();
  }
  block = idx;
}
inline void out(int idx) {
  cout << sum[idx] << "\n";
  for (int i = 0; i < block; ++i) {
    for (auto it : res[i][idx]) cout << it << " ";
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    char col;
    cin >> u >> v >> col;
    G[u].push_back({v, (col == 'B')});
    G[v].push_back({u, (col == 'B')});
  }
  tag = 0;
  slove();
  tag = 1;
  slove();
  if (sum[0] == 0x3f3f3f3f && sum[1] == 0x3f3f3f3f)
    cout << "-1";
  else
    sum[0] > sum[1] ? out(1) : out(0);
  return 0;
}
