#include <bits/stdc++.h>
const int oo = INT_MAX;
const long long int OO = (1LL << 62);
using namespace std;
namespace {
template <typename Iter>
std::ostream& _out(std::ostream& s, Iter b, Iter e) {
  s << "[";
  for (auto it = b; it != e; it++) s << (it == b ? "" : " ") << *it;
  s << "]";
  return s;
}
template <typename A, typename B>
std::ostream& operator<<(std::ostream& s, const std::pair<A, B>& p) {
  return s << "(" << p.first << "," << p.second << ")";
}
template <typename T>
std::ostream& operator<<(std::ostream& s, const std::vector<T>& c) {
  return _out(s, begin(c), end(c));
}
template <typename T>
std::ostream& operator<<(std::ostream& s, const std::set<T>& c) {
  return _out(s, begin(c), end(c));
}
template <typename A, typename B>
std::ostream& operator<<(std::ostream& s, const std::map<A, B>& c) {
  return _out(s, begin(c), end(c));
}
template <typename T>
void _dump(const char* s, T&& head) {
  std::cerr << s << "=" << head << std::endl;
}
template <typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
  int c = 0;
  while (*s != ',' || c != 0) {
    if (*s == '(' || *s == '[' || *s == '{') c++;
    if (*s == ')' || *s == ']' || *s == '}') c--;
    std::cerr << *s++;
  }
  std::cerr << "=" << head << ", ";
  _dump(s + 1, tail...);
}
void RI() {}
template <typename... T>
void RI(int& head, T&... tail) {
  scanf("%d", &head);
  RI(tail...);
}
}  // namespace
vector<pair<int, bool>> adj[100005];
vector<int> visited;
deque<bool> flipped_vertices[2];
vector<int> flip_list[2];
int N, M, ATTEMPT;
bool C;
bool dfs(int vertex, bool flipped) {
  if (flipped) {
    flipped_vertices[ATTEMPT][vertex] = true;
    flip_list[ATTEMPT].push_back(vertex);
  }
  visited[vertex] = ATTEMPT + 1;
  bool ret = true;
  for (const auto& p : adj[vertex]) {
    auto to_flip = flipped ^ p.second ^ C;
    if (visited[p.first] == ATTEMPT + 1) {
      if (to_flip ^ flipped_vertices[ATTEMPT][p.first]) {
        return false;
      }
    } else {
      if (!dfs(p.first, to_flip)) return false;
    }
  }
  return ret;
}
bool try_solve(vector<int>* output) {
  visited.assign(N + 2, 0);
  flipped_vertices[0].assign(N + 2, false);
  flipped_vertices[1].assign(N + 2, false);
  for (int i = 1; i <= N; ++i) {
    if (!visited[i]) {
      flip_list[0].clear();
      flip_list[1].clear();
      vector<int>* mn = nullptr;
      ATTEMPT = 0;
      if (dfs(i, false)) {
        mn = &flip_list[0];
      }
      ATTEMPT = 1;
      if (dfs(i, true) and
          (mn == nullptr or mn->size() > flip_list[1].size())) {
        mn = &flip_list[1];
      }
      if (mn == nullptr)
        return false;
      else
        copy(mn->begin(), mn->end(), back_inserter(*output));
    }
  }
  return true;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 1; i <= M; ++i) {
    int x, y;
    bool c;
    string str;
    cin >> x >> y >> str;
    c = (str[0] == 'R');
    adj[x].emplace_back(y, c);
    adj[y].emplace_back(x, c);
  }
  C = 0;
  vector<int> x;
  bool xb = try_solve(&x);
  C = 1;
  vector<int> y;
  bool yb = try_solve(&y);
  if (!xb and !yb) {
    cout << "-1"
         << "\n";
    return 0;
  }
  vector<int>* ans = nullptr;
  if (xb) ans = &x;
  if (yb and (ans == nullptr or ans->size() > y.size())) ans = &y;
  cout << ans->size() << "\n";
  for (int a : *ans) {
    cout << a << " ";
  }
  cout << "\n";
  return 0;
}
