#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
template <typename T>
inline void read(T& x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && c != '-')
    ;
  if (c == '-') {
    c = getchar();
    nega = 1;
  }
  x = c - 48;
  while (isdigit(c = getchar())) {
    x = x * 10 + c - 48;
  }
  if (nega) x = -x;
}
template <typename T>
void Write(T x) {
  if (x > 9) Write(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  Write(x);
  putchar(' ');
}
template <typename T>
void writeln(T x) {
  write(x);
  putchar('\n');
}
const int N = 1e5 + 1;
int n, m;
vector<pair<int, int> > adj[N];
int vst[N];
vector<int> s[2];
bool ok;
bool dfs(int u, int p, int c) {
  if (vst[u] != -1) {
    return vst[u] == p;
  }
  vst[u] = p;
  s[p].push_back(u);
  for (auto x : adj[u]) {
    int next_p = p;
    if (x.second != c) next_p = 1 - p;
    if (!dfs(x.first, next_p, c)) return 0;
  }
  return 1;
}
vector<int> solve(int c) {
  for (int i = 1; i <= n; i++) vst[i] = -1;
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (vst[i] == -1) {
      s[0].clear();
      s[1].clear();
      bool ok = dfs(i, 1, c);
      if (!ok) {
        for (int k = 1; k <= n + 1; k++) ans.push_back(0);
        return ans;
      }
      if (s[0].size() > s[1].size()) swap(s[0], s[1]);
      for (int x : s[0]) ans.push_back(x);
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    adj[u].push_back({v, c == 'B'});
    adj[v].push_back({u, c == 'B'});
  }
  vector<int> v0 = solve(0);
  vector<int> v1 = solve(1);
  if (v0.size() > v1.size()) swap(v0, v1);
  if (v0.size() > n) {
    cout << -1;
    return 0;
  }
  cout << v0.size() << '\n';
  for (int x : v0) cout << x << ' ';
  return 0;
}
