#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
template <typename first, typename second>
ostream& operator<<(ostream& os, const pair<first, second>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream& operator<<(ostream& os, const map<first, second>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
void faltu() { cerr << '\n'; }
template <typename T>
void faltu(T a[], int n) {
  for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
  cerr << '\n';
}
template <typename T, typename... hello>
void faltu(T arg, const hello&... rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
const int mx = 1e5 + 5;
int n, m;
vector<pair<int, char>> adjlist[mx];
int lvl[mx];
vector<int> vec1, vec2;
vector<int> store;
bool ok = 0;
void bfs(int source, char ch) {
  queue<int> q;
  q.push(source);
  lvl[source] = 0;
  int total = 0;
  int zero = 0;
  vector<int> vec_zero, vec_one;
  while (!q.empty()) {
    int u = q.front();
    if (lvl[u] == 0) {
      ++zero;
      vec_zero.push_back(u);
    } else {
      vec_one.push_back(u);
    }
    ++total;
    q.pop();
    for (auto v : adjlist[u]) {
      if (lvl[v.first] == -1) {
        q.push(v.first);
        if (v.second == ch)
          lvl[v.first] = lvl[u];
        else
          lvl[v.first] = 1 - lvl[u];
      } else {
        if (v.second == ch) {
          if (lvl[v.first] != lvl[u]) {
            ok = 1;
            return;
          }
        } else {
          if (lvl[v.first] == lvl[u]) {
            ok = 1;
            return;
          }
        }
      }
    }
  }
  if (zero < total - zero) {
    for (auto x : vec_zero) store.push_back(x);
  } else {
    for (auto x : vec_one) store.push_back(x);
  }
}
vector<int> solve(char ch) {
  ok = 0;
  store.clear();
  memset(lvl, -1, sizeof(lvl));
  for (int i = 1; i <= n; ++i) {
    if (lvl[i] == -1) {
      bfs(i, ch);
    }
  }
  if (ok)
    while ((int)store.size() < n + 5) store.push_back(0);
  return store;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    char ch;
    cin >> u >> v >> ch;
    adjlist[u].push_back(make_pair(v, ch));
    adjlist[v].push_back(make_pair(u, ch));
  }
  vec1 = solve('R');
  vec2 = solve('B');
  if ((int)vec1.size() > (int)vec2.size()) swap(vec1, vec2);
  if ((int)vec1.size() > n) {
    cout << -1 << '\n';
    return 0;
  }
  random_shuffle(vec1.begin(), vec1.end());
  random_shuffle(vec1.begin(), vec1.end());
  random_shuffle(vec1.begin(), vec1.end());
  cout << (int)vec1.size() << '\n';
  for (auto x : vec1) cout << x << " ";
  cout << '\n';
}
