#include <bits/stdc++.h>
using namespace std;
void errDebug() {}
template <typename T, typename... Args>
void errDebug(T a, Args... args) {
  cerr << a << ' ';
  errDebug(args...);
}
int n, m;
vector<pair<int, int> > g[100100];
int statu[100100];
int statu2[100100];
bool ok1;
bool ok2;
vector<int> vec1;
vector<int> vec2;
vector<int> v[2];
void DFS1(int index, int change, int color) {
  if (statu[index] != -1) {
    if (statu[index] != change) {
      ok1 = false;
    }
    return;
  }
  if (change) vec1.push_back(index + 1);
  statu[index] = change;
  for (int(i) = (0); (i) < (g[index].size()); ++(i)) {
    int v = g[index][i].first;
    int c = g[index][i].second ^ change;
    DFS1(v, (c != color), color);
  }
}
void DFS2(int index, int change, int color) {
  if (statu2[index] != -1) {
    if (statu2[index] != change) {
      ok2 = false;
    }
    return;
  }
  if (change) vec2.push_back(index + 1);
  statu2[index] = change;
  for (int(i) = (0); (i) < (g[index].size()); ++(i)) {
    int v = g[index][i].first;
    int c = g[index][i].second ^ change;
    DFS2(v, (c != color), color);
  }
}
int color;
long long solve() {
  long long ans[2];
  memset(ans, 0, sizeof ans);
  for (int(c) = (0); (c) < (2); ++(c)) {
    memset(statu, -1, sizeof statu);
    memset(statu2, -1, sizeof statu2);
    for (int(i) = (0); (i) < (n); ++(i)) {
      if (statu[i] != -1) continue;
      ok1 = true;
      ok2 = true;
      vec1.clear();
      vec2.clear();
      DFS1(i, 0, c);
      DFS2(i, 1, c);
      int res = 0x3f3f3f3f;
      if (ok1) res = min(res, (int)vec1.size());
      if (ok2) res = min(res, (int)vec2.size());
      ans[c] += res;
      if (res == vec1.size()) {
        for (int(j) = (0); (j) < (vec1.size()); ++(j)) v[c].push_back(vec1[j]);
      } else {
        for (int(j) = (0); (j) < (vec2.size()); ++(j)) v[c].push_back(vec2[j]);
      }
    }
  }
  if (ans[0] >= 0x3f3f3f3f && ans[1] >= 0x3f3f3f3f) return -1;
  if (ans[0] <= ans[1])
    color = 0;
  else
    color = 1;
  return min(ans[0], ans[1]);
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(false);
  cin >> n >> m;
  for (int(i) = (0); (i) < (m); ++(i)) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    x--;
    y--;
    if (c == 'B') {
      g[x].push_back(make_pair(y, 0));
      g[y].push_back(make_pair(x, 0));
    } else {
      g[x].push_back(make_pair(y, 1));
      g[y].push_back(make_pair(x, 1));
    }
  }
  long long res = solve();
  if (res != -1) {
    cout << res << endl;
    for (int(i) = (0); (i) < (v[color].size()); ++(i))
      cout << v[color][i] << " ";
    cout << endl;
  } else
    cout << res << endl;
  return 0;
}
