#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MAXN = 100009;
int n, m;
vector<pair<int, int> > adj[MAXN];
bool vis[MAXN];
int color[MAXN];
vector<int> possible;
int bfs(int source, int t) {
  queue<int> q;
  q.push(source);
  vis[source] = true;
  set<int> used;
  used.insert(source);
  color[source] = 0;
  bool ok = true;
  int cnt0 = 1;
  int cnt1 = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i].first;
      int c = adj[u][i].second;
      if (vis[v]) {
        if (color[v] == color[u] && c != t) {
          ok = false;
        } else if (color[v] != color[u] && c == t) {
          ok = false;
        }
      } else {
        if (c != t)
          color[v] = 1 - color[u];
        else
          color[v] = color[u];
        if (color[v] == 1)
          cnt1++;
        else
          cnt0++;
        vis[v] = true;
        used.insert(v);
        q.push(v);
      }
    }
  }
  if (!ok) {
    return -1;
  }
  int win = cnt0 < cnt1 ? 0 : 1;
  for (typeof(used.begin()) it = (used.begin()); it != used.end(); it++) {
    int id = *it;
    if (color[id] == win) possible.push_back(id);
  }
  return min(cnt0, cnt1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    u--;
    v--;
    int cc = c == 'R' ? 0 : 1;
    adj[u].push_back(make_pair(v, cc));
    adj[v].push_back(make_pair(u, cc));
  }
  int res = INF;
  int suma = 0;
  for (int i = 0; i < n; i++) {
    vis[i] = false;
    color[i] = -1;
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      int cant = bfs(i, 0);
      if (cant == -1) {
        suma = INF;
        break;
      } else {
        suma += cant;
      }
    }
  }
  vector<int> ans;
  res = min(res, suma);
  if (res < INF) ans = possible;
  possible.clear();
  suma = 0;
  for (int i = 0; i < n; i++) {
    vis[i] = false;
    color[i] = -1;
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      int cant = bfs(i, 1);
      if (cant == -1) {
        suma = INF;
        break;
      } else {
        suma += cant;
      }
    }
  }
  res = min(res, suma);
  if (res != ans.size() && res != INF) {
    ans = possible;
  }
  if (res == INF) {
    cout << -1 << endl;
  } else {
    cout << res << endl;
    for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << endl;
  }
  return 0;
}
