#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
int n, m;
vector<vector<int> > c;
vector<int> used;
int kols[2];
bool dfs(int v, int ind) {
  kols[used[v] & 1]++;
  for (int i = 0; i < (int)gr[v].size(); ++i) {
    int nv = gr[v][i];
    int nc = used[v] ^ (ind != c[v][i]);
    if (used[nv] < 0) {
      used[nv] = nc;
      if (!dfs(nv, ind)) return false;
    } else if (nc != used[nv]) {
      return false;
    }
  }
  return true;
}
vector<int> findAns(int ind) {
  used.assign(n, -1);
  int indd = 0;
  vector<int> res(n + 1, 0);
  for (int i = 0; i < n; ++i)
    if (used[i] < 0) {
      used[i] = indd;
      kols[0] = kols[1] = 0;
      if (!dfs(i, ind)) return vector<int>();
      if (kols[0] < kols[1])
        res[indd] = 1;
      else
        res[indd + 1] = 1;
      indd += 2;
    }
  vector<int> ans;
  for (int i = 0; i < n; ++i)
    if (res[used[i]]) ans.push_back(i + 1);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  gr.assign(n, vector<int>());
  c.assign(n, vector<int>());
  int kol[2] = {0, 0};
  for (int i = 0; i < m; ++i) {
    int v1, v2;
    char cc;
    cin >> v1 >> v2 >> cc;
    --v1;
    --v2;
    gr[v1].push_back(v2);
    c[v1].push_back(cc == 'R');
    gr[v2].push_back(v1);
    c[v2].push_back(cc == 'R');
    kol[cc == 'R']++;
  }
  if (kol[0] == 0 || kol[1] == 0) {
    cout << "0\n";
    return 0;
  }
  vector<int> ans0 = findAns(0);
  vector<int> ans1 = findAns(1);
  if (ans0.size() > ans1.size()) swap(ans0, ans1);
  if (ans0.empty()) ans0.swap(ans1);
  if (ans0.empty()) {
    cout << "-1\n";
    return 0;
  }
  cout << ans0.size() << "\n";
  for (int i = 0; i < (int)ans0.size(); ++i) cout << ans0[i] << ' ';
  cout << "\n";
  return 0;
}
