#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
const int INF = 1e9;
int n, yal, moalefe;
int flag_R, flag_B, Group_R[maxx], Group_B[maxx], par[maxx];
bool mark[maxx], hast_R[maxx], hast_B[maxx];
vector<pair<int, int> > adj[maxx];
vector<int> m[maxx];
vector<int> ans_B, ans_R;
void DFS_R(int v) {
  mark[v] = true;
  m[moalefe].push_back(v);
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first;
    int w = adj[v][i].second;
    if (!mark[u]) {
      par[u] = v;
      if (w == 0)
        Group_R[u] = Group_R[v] ^ 1;
      else
        Group_R[u] = Group_R[v];
      DFS_R(u);
    } else {
      if (u != par[v]) {
        if (Group_R[u] != Group_R[v] && w == 1) flag_R = INF;
        if (Group_R[u] == Group_R[v] && w == 0) flag_R = INF;
      }
    }
  }
}
void DFS_B(int v) {
  mark[v] = true;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first;
    int w = adj[v][i].second;
    if (!mark[u]) {
      par[u] = v;
      if (w == 1)
        Group_B[u] = Group_B[v] ^ 1;
      else
        Group_B[u] = Group_B[v];
      DFS_B(u);
    } else {
      if (u != par[v]) {
        if (Group_B[u] != Group_B[v] && w == 0) flag_B = INF;
        if (Group_B[u] == Group_B[v] && w == 1) flag_B = INF;
      }
    }
  }
}
void DFS_ALLr() {
  for (int i = 0; i < n; i++)
    if (!mark[i]) {
      Group_R[i] = 1;
      DFS_R(i);
      moalefe++;
    }
}
void DFS_ALLb() {
  for (int i = 0; i < n; i++)
    if (!mark[i]) {
      Group_B[i] = 1;
      DFS_B(i);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> yal;
  for (int i = 0; i < yal; i++) {
    int u, v, w;
    char c;
    cin >> u >> v >> c;
    u--;
    v--;
    if (c == 'R')
      w = 1;
    else
      w = 0;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  DFS_ALLr();
  memset(mark, 0, sizeof mark);
  memset(par, 0, sizeof par);
  DFS_ALLb();
  if (flag_R == INF && flag_B == INF) {
    cout << "-1"
         << "\n";
    return 0;
  }
  if (flag_R != INF) {
    for (int i = 0; i < moalefe; i++) {
      int cnt_R = 0;
      for (int j = 0; j < (int)m[i].size(); j++)
        if (Group_R[m[i][j]] == 1) hast_R[m[i][j]] = true, cnt_R++;
      if (cnt_R <= (int)m[i].size() - cnt_R) {
        for (int j = 0; j < (int)m[i].size(); j++)
          if (hast_R[m[i][j]]) ans_R.push_back(m[i][j]);
      } else {
        for (int j = 0; j < (int)m[i].size(); j++)
          if (!hast_R[m[i][j]]) ans_R.push_back(m[i][j]);
      }
    }
  }
  if (flag_B != INF) {
    for (int i = 0; i < moalefe; i++) {
      int cnt_B = 0;
      for (int j = 0; j < (int)m[i].size(); j++)
        if (Group_B[m[i][j]] == 1) hast_B[m[i][j]] = true, cnt_B++;
      if (cnt_B <= (int)m[i].size() - cnt_B) {
        for (int j = 0; j < (int)m[i].size(); j++)
          if (hast_B[m[i][j]]) ans_B.push_back(m[i][j]);
      } else {
        for (int j = 0; j < (int)m[i].size(); j++)
          if (!hast_B[m[i][j]]) ans_B.push_back(m[i][j]);
      }
    }
  }
  if (flag_B == INF && flag_R != INF) {
    cout << (int)ans_R.size() << "\n";
    for (int i = 0; i < (int)ans_R.size(); i++) cout << ans_R[i] + 1 << " ";
    return 0;
  }
  if (flag_B != INF && flag_R == INF) {
    cout << (int)ans_B.size() << "\n";
    for (int i = 0; i < (int)ans_B.size(); i++) cout << ans_B[i] + 1 << " ";
    return 0;
  }
  if ((int)ans_R.size() <= (int)ans_B.size()) {
    cout << (int)ans_R.size() << "\n";
    for (int i = 0; i < (int)ans_R.size(); i++) cout << ans_R[i] + 1 << " ";
    return 0;
  }
  cout << (int)ans_B.size() << "\n";
  for (int i = 0; i < (int)ans_B.size(); i++) cout << ans_B[i] + 1 << " ";
  return 0;
}
