#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const int N = 1e5 + 4;
vector<int> cur[2];
int vis[N];
vector<pair<int, int> > adjlist[N];
vector<pair<pair<int, int>, int> > edg;
int c[N];
void dfs(int node, int color) {
  c[node] = color;
  vis[node] = 1;
  cur[color].push_back(node);
  for (auto i : adjlist[node]) {
    int parity = i.second;
    int j = i.first;
    if (!vis[j]) {
      dfs(j, color ^ parity);
    }
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    char type;
    cin >> u >> v >> type;
    int w = (type == 'B');
    edg.push_back(make_pair(make_pair(u, v), w));
    adjlist[u].push_back(make_pair(v, w));
    adjlist[v].push_back(make_pair(u, w));
  }
  vector<int> ans;
  for (int i = 1; i < n + 1; ++i) {
    if (!vis[i]) {
      for (int j = 0; j < 2; ++j) cur[j].clear();
      dfs(i, 0);
      if ((int)cur[0].size() > (int)cur[1].size()) {
        swap(cur[0], cur[1]);
      }
      for (int j : cur[0]) ans.push_back(j);
    }
  }
  int f1 = 1;
  for (int i = 0; i < m; ++i) {
    int u = edg[i].first.first;
    int v = edg[i].first.second;
    int w = edg[i].second;
    if ((c[u] ^ c[v]) != w) {
      f1 = 0;
      break;
    }
  }
  for (int i = 0; i < m; ++i) {
    edg[i].second ^= 1;
  }
  for (int i = 1; i < n + 1; ++i) {
    for (auto &j : adjlist[i]) {
      j.second ^= 1;
    }
  }
  int f2 = 1;
  memset(vis, 0, sizeof vis);
  memset(c, 0, sizeof c);
  vector<int> ans2;
  for (int i = 1; i < n + 1; ++i) {
    if (!vis[i]) {
      for (int j = 0; j < 2; ++j) cur[j].clear();
      dfs(i, 0);
      if ((int)cur[0].size() > (int)cur[1].size()) {
        swap(cur[0], cur[1]);
      }
      for (int j : cur[0]) ans2.push_back(j);
    }
  }
  for (int i = 0; i < m; ++i) {
    int u = edg[i].first.first;
    int v = edg[i].first.second;
    int w = edg[i].second;
    if ((c[u] ^ c[v]) != w) {
      f2 = 0;
      break;
    }
  }
  if (!f1 && !f2) {
    cout << -1 << '\n';
    return;
  } else if (f1 && f2) {
    if ((int)ans.size() > (int)ans2.size()) {
      swap(ans, ans2);
    }
  } else if (f2) {
    swap(ans2, ans);
  }
  cout << (int)ans.size() << '\n';
  for (int i : ans) {
    cout << i << ' ';
  }
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
