#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& _p) {
  return os << "(" << _p.first << "," << _p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& _V) {
  bool f = true;
  os << "[";
  for (auto v : _V) {
    os << (f ? "" : ",") << v;
    f = false;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& _S) {
  bool f = true;
  os << "(";
  for (auto s : _S) {
    os << (f ? "" : ",") << s;
    f = false;
  }
  return os << ")";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& _M) {
  return os << set<pair<T, U>>(_M.begin(), _M.end());
}
const signed long long INF = 1000000100;
const long double EPS = 1e-9;
struct two_sat {
  int n;
  vector<vector<int>> G;
  vector<int> v_value;
  vector<bool> v_visited;
  vector<int> order;
  bool conflict;
  vector<int> meh;
  two_sat(int _n)
      : n(_n),
        G(2 * n),
        v_value(2 * n, -1),
        v_visited(2 * n, false),
        conflict(false) {}
  inline void add(int a, int b) {
    G[a ^ 1].push_back(b);
    G[b ^ 1].push_back(a);
  }
  void dfs1(int v) {
    v_visited[v] = true;
    for (auto u : G[v ^ 1])
      if (!v_visited[u ^ 1]) dfs1(u ^ 1);
    order.push_back(v);
  }
  void dfs2(int v) {
    v_visited[v] = true;
    v_value[v] = (v_value[v ^ 1] == -1);
    for (auto u : G[v])
      if (!v_visited[u]) dfs2(u);
  }
  void dfs3(int v) {
    meh.push_back(v);
    v_visited[(2 * (v))] = true;
    v_visited[(2 * (v) + 1)] = true;
    for (auto u : G[(2 * (v))])
      if (!v_visited[u]) dfs3(u / 2);
  }
  void run() {
    for (int(v) = (0); (v) < (2 * n); (v)++)
      if (!v_visited[v]) dfs1(v);
    for (int(v) = (0); (v) < (2 * n); (v)++) v_visited[v] = false;
    reverse(order.begin(), order.end());
    for (int v : order)
      if (!v_visited[v]) dfs2(v);
    for (int(v) = (0); (v) < (2 * n); (v)++)
      if (v_value[v]) {
        for (auto u : G[v])
          if (!v_value[u]) {
            conflict = true;
            return;
          }
      }
    for (int(v) = (0); (v) < (2 * n); (v)++) v_visited[v] = false;
    for (int(v) = (0); (v) < (n); (v)++) {
      if (!v_visited[(2 * (v))]) {
        meh.clear();
        dfs3(v);
        int cnt = 0, tot = int(meh.size());
        for (int x : meh) {
          if (v_value[(2 * (x))]) cnt++;
        }
        if (tot - cnt < cnt) {
          for (int x : meh) {
            v_value[(2 * (x))] = !v_value[(2 * (x))];
            v_value[(2 * (x) + 1)] = !v_value[(2 * (x) + 1)];
          }
        }
      }
    }
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  two_sat make_blue(n), make_red(n);
  for (int(i) = (1); (i) <= (m); (i)++) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    a--;
    b--;
    if (c == 'R') {
      make_red.add((2 * (a) + 1), (2 * (b)));
      make_red.add((2 * (a)), (2 * (b) + 1));
      make_blue.add((2 * (a) + 1), (2 * (b) + 1));
      make_blue.add((2 * (a)), (2 * (b)));
    } else {
      make_red.add((2 * (a) + 1), (2 * (b) + 1));
      make_red.add((2 * (a)), (2 * (b)));
      make_blue.add((2 * (a) + 1), (2 * (b)));
      make_blue.add((2 * (a)), (2 * (b) + 1));
    }
  }
  for (int(i) = (0); (i) < (n); (i)++) {
    make_blue.add((2 * (i)), (2 * (i) + 1));
    make_red.add((2 * (i)), (2 * (i) + 1));
  }
  int ok = 0;
  make_blue.run();
  vector<int> v;
  if (!make_blue.conflict) {
    ok = 1;
    int cnt = 0, tg = 1;
    for (int(i) = (0); (i) < (n); (i)++) {
      if (make_blue.v_value[(2 * (i))] == 1) cnt++;
    }
    if (n - cnt < cnt) tg = 0;
    for (int(i) = (0); (i) < (n); (i)++) {
      if (make_blue.v_value[(2 * (i))] == tg) v.push_back(i + 1);
    }
  }
  make_red.run();
  vector<int> vr;
  if (!make_red.conflict) {
    int cnt = 0, tg = 1;
    for (int(i) = (0); (i) < (n); (i)++) {
      if (make_red.v_value[(2 * (i))] == 1) cnt++;
    }
    if (n - cnt < cnt) tg = 0;
    for (int(i) = (0); (i) < (n); (i)++) {
      if (make_red.v_value[(2 * (i))] == tg) vr.push_back(i + 1);
    }
    if (!ok || int(vr.size()) < int(v.size())) v = vr;
    ok = 1;
  }
  if (!ok)
    cout << "-1\n";
  else {
    cout << int(v.size()) << "\n";
    for (int x : v) cout << x << " ";
    cout << "\n";
  }
}
