#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
vector<pair<int, int> > lst[N];
int ans = 0;
vector<int> tmp;
bool used[N];
int st1[N];
bool gl[N];
int st[N];
int cnt = 0;
bool dfs(int k) {
  used[k] = 1;
  tmp.push_back(k);
  cnt += st[k];
  for (int i = 0; i < (int)lst[k].size(); i++) {
    int to = lst[k][i].first;
    if (!used[to]) {
      st[to] = (st[k] + lst[k][i].second) % 2;
      bool tt = dfs(to);
      if (!tt) return false;
    } else {
      if ((st[k] + st[to] + lst[k][i].second) % 2) return false;
    }
  }
  return true;
}
int n, m;
void solve() {
  for (int i = 1; i <= n; i++) {
    used[i] = 0;
    st[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      tmp.clear();
      cnt = 0;
      if (!dfs(i)) {
        ans = 1e9;
        return;
      }
      if (tmp.size() - cnt < cnt) {
        ans += tmp.size() - cnt;
        for (int j = 0; j < (int)tmp.size(); j++) {
          st[tmp[j]] = 1 - st[tmp[j]];
        }
      } else {
        ans += cnt;
      }
    }
  }
}
void bad() {
  cout << -1 << endl;
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    if (c == 'B')
      lst[u].push_back(make_pair(v, 0));
    else
      lst[u].push_back(make_pair(v, 1));
    if (c == 'B')
      lst[v].push_back(make_pair(u, 0));
    else
      lst[v].push_back(make_pair(u, 1));
  }
  solve();
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (int)lst[i].size(); j++) {
      lst[i][j].second = 1 - lst[i][j].second;
    }
  }
  int ans1 = ans;
  ans = 0;
  memcpy(st1, st, (n + 10) * sizeof(int));
  solve();
  if (ans > ans1) {
    swap(ans, ans1);
    swap(st, st1);
  }
  if (ans >= 1e9 - 1) {
    bad();
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    if (st[i]) {
      cout << i << " ";
    }
  }
  return 0;
}
