#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v0, v1;
vector<int> solve(vector<vector<int> > v, int n, bool& has) {
  has = true;
  vector<int> res;
  vector<int> used(n + 1, -1);
  for (int i = 1; i <= n; i++) {
    if (used[i] != -1) continue;
    used[i] = 0;
    queue<int> q;
    vector<int> cmp;
    q.push(i);
    while (!q.empty()) {
      int x = q.front();
      cmp.push_back(x);
      q.pop();
      for (int to : v[x]) {
        int t = abs(to);
        int wnt = used[x];
        if (to < 0) wnt ^= 1;
        if (used[t] == -1) {
          used[t] = wnt;
          q.push(t);
          continue;
        }
        if (used[t] != wnt) {
          has = false;
          return res;
        }
      }
    }
    int c0 = 0, c1 = 0;
    for (int x : cmp) {
      if (used[x] == 0)
        c0++;
      else
        c1++;
    }
    int swp = 0;
    if (c1 > c0) swp = 1;
    for (int x : cmp) {
      if (used[x] ^ swp) {
        res.push_back(x);
      }
    }
  }
  has = true;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  v0.resize(n + 1);
  v1.resize(n + 1);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    char c;
    cin >> c;
    if (c == 'B') {
      v0[x].push_back(y);
      v0[y].push_back(x);
      v1[x].push_back(-y);
      v1[y].push_back(-x);
    } else {
      v0[x].push_back(-y);
      v0[y].push_back(-x);
      v1[x].push_back(y);
      v1[y].push_back(x);
    }
  }
  bool tmp = false;
  bool has = false;
  vector<int> ans;
  vector<int> ans1 = solve(v0, n, tmp);
  if (tmp) {
    has = true;
    ans = ans1;
  }
  vector<int> ans2 = solve(v1, n, tmp);
  if (tmp) {
    if (has == false || ans.size() > ans2.size()) {
      ans = ans2;
    }
    has = true;
  }
  if (!has) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (int x : ans) cout << x << " ";
  return 0;
}
