#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const int INF = 1 << 30;
int par[MAXN];
int find(int x) { return x == par[x] ? x : par[x] = find(par[x]); }
void join(int a, int b) { par[find(a)] = par[find(b)]; }
int N, M;
vector<pair<int, int> > adj[MAXN];
vector<int> comp[MAXN];
int flip[2][MAXN];
int *use = nullptr;
void reset(int cur, int targ) {
  for (int x : comp[cur]) {
    flip[targ][x] = -1;
  }
}
int bfs(int st, int targ, int isflip) {
  reset(find(st), targ);
  int *tflip = flip[targ];
  bool bad = false;
  int cnt = 0;
  queue<pair<int, int> > q;
  q.push(pair<int, int>(st, isflip));
  while (!q.empty()) {
    int cur = q.front().first;
    int cflip = q.front().second;
    q.pop();
    if (tflip[cur] != -1) {
      if (tflip[cur] != cflip) bad = true;
      continue;
    }
    tflip[cur] = cflip;
    cnt += cflip;
    for (pair<int, int> p : adj[cur]) {
      int nxt = p.first;
      int col = p.second;
      int nflip = targ ^ col ^ cflip;
      q.push(pair<int, int>(nxt, nflip));
    }
  }
  if (bad) cnt = INF;
  return cnt;
}
int getcnt(int cur, int targ) {
  int a = bfs(cur, targ, 0);
  int b = bfs(cur, targ, 1);
  if (a < b) {
    bfs(cur, targ, 0);
    return a;
  }
  bfs(cur, targ, 1);
  return b;
}
int go() {
  memset(flip, -1, sizeof(flip));
  int cnt = INF;
  for (int targ = 0; targ < 2; ++targ) {
    int sum = 0;
    for (int i = 0; i < N; ++i) {
      if (i == find(i)) {
        int cur = getcnt(i, targ);
        if (cur == INF) {
          sum = INF;
          break;
        } else {
          sum += cur;
        }
      }
    }
    if (cnt > sum) {
      cnt = sum;
      use = flip[targ];
    }
  }
  return cnt;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; ++i) par[i] = i;
  for (int i = 0; i < M; ++i) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    --a, --b;
    join(a, b);
    adj[a].push_back(pair<int, int>(b, c == 'R'));
    adj[b].push_back(pair<int, int>(a, c == 'R'));
  }
  for (int i = 0; i < N; ++i) {
    comp[find(i)].push_back(i);
  }
  int ans = go();
  if (ans == INF) {
    cout << "-1\n";
  } else {
    assert(use != nullptr);
    cout << ans << '\n';
    for (int i = 0; i < N; ++i) {
      if (use[i]) cout << i + 1 << ' ';
    }
  }
  return 0;
}
