#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<pair<int, char> > G[N];
int vis[N];
vector<int> MARK[3];
int n, m;
bool dfs(int u, int mark, char color) {
  if (vis[u]) return vis[u] == mark;
  vis[u] = mark;
  MARK[mark].push_back(u);
  for (int i = 0; i < G[u].size(); i++) {
    int tpmark;
    if (color == G[u][i].second)
      tpmark = mark;
    else
      tpmark = 3 - mark;
    if (!dfs(G[u][i].first, tpmark, color)) return false;
  }
  return true;
}
vector<int> solve(char color) {
  memset(vis, 0, sizeof(vis));
  vector<int> ans;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      MARK[1].clear();
      MARK[2].clear();
      if (!dfs(i, 1, color)) {
        ans.clear();
        for (int i = 1; i <= 2 * n; i++) ans.push_back(1);
        return ans;
      }
      int select = 1;
      if (MARK[1].size() > MARK[2].size()) select = 2;
      for (int i = 0; i < MARK[select].size(); i++)
        ans.push_back(MARK[select][i]);
    }
  return ans;
}
int main() {
  char s[3];
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; i++) G[i].clear();
    for (int i = 1; i <= m; i++) {
      int u, v;
      char c;
      scanf("%d%d%s", &u, &v, s);
      c = s[0];
      G[u].push_back(make_pair(v, c));
      G[v].push_back(make_pair(u, c));
    }
    vector<int> A = solve('R');
    vector<int> B = solve('B');
    if (A.size() > B.size()) swap(A, B);
    if (A.size() > n)
      puts("-1");
    else {
      printf("%d\n", A.size());
      for (int i = 0; i < A.size(); i++) printf("%d ", A[i]);
      printf("\n");
    }
  }
  return 0;
}
