#include <bits/stdc++.h>
using namespace std;
queue<int> q;
vector<pair<int, char> > G[100005];
int n, m, cnt1, cnt2, want, ans = -1;
int color[100005], res[100005];
void dfs(int u) {
  if (color[u])
    cnt1++;
  else
    cnt2++;
  q.push(u);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first, c = G[u][i].second ^ want ^ color[u];
    if (color[v] == -1) {
      color[v] = c, dfs(v);
      if (cnt1 < 0) return;
    } else if (color[v] != c) {
      cnt1 = -1;
      return;
    }
  }
}
void solve(int opt) {
  int cnt = 0;
  want = opt;
  memset(color, -1, sizeof(color));
  for (int i = 1; i <= n; i++)
    if (color[i] == -1) {
      while (!q.empty()) q.pop();
      cnt1 = cnt2 = 0, color[i] = 1, dfs(i);
      if (cnt1 < 0) {
        cnt = -1;
        break;
      }
      cnt += (cnt1 < cnt2) ? cnt1 : cnt2;
      bool p = cnt1 > cnt2;
      while (!q.empty()) color[q.front()] ^= p, q.pop();
    }
  if ((ans == -1 || ans > cnt) && cnt != -1) {
    for (int i = 1; i <= n; i++) res[i] = color[i];
    ans = cnt;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    char c;
    scanf("%d %d %c", &u, &v, &c);
    G[u].push_back(make_pair(v, (c == 'R')));
    G[v].push_back(make_pair(u, (c == 'R')));
  }
  solve(0);
  solve(1);
  printf("%d\n", ans);
  if (ans != -1)
    for (int i = 1; i <= n; i++)
      if (res[i] == 1) printf("%d ", i);
  return 0;
}
