#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
const int maxm = 3 * maxn;
vector<pair<int, int> > G[maxn];
vector<int> mp;
int vis[maxn], vis1[maxn], ans1, ans;
int vis2[maxn], vis3[maxn];
bool dfs(int u, int num) {
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first, w = G[u][i].second;
    if (vis[v] != 0) {
      if (w == num) {
        if (vis[u] != vis[v]) return false;
        continue;
      } else {
        if (vis[u] == vis[v]) return false;
        continue;
      }
    }
    if (w == num) {
      vis[v] = vis[u];
      mp.push_back(v);
      if (vis[v] == 2) ans1++;
      if (!dfs(v, num)) return false;
    } else {
      vis[v] = 3 - vis[u];
      mp.push_back(v);
      if (vis[v] == 2) ans1++;
      if (!dfs(v, num)) return false;
    }
  }
  return true;
}
void solve(int n) {
  memset(vis, 0, sizeof(vis)), memset(vis1, 0, sizeof(vis1)),
      memset(vis2, 0, sizeof(vis2)), memset(vis3, 0, sizeof(vis3));
  int ANS = 0;
  for (int i = 1; i <= n; i++) {
    if (vis1[i] == 1) continue;
    ans1 = 0, vis[i] = 1;
    int flag1 = 0, flag2 = 0;
    mp.push_back(i);
    if (dfs(i, 1)) flag1 = 1;
    for (int j = 0; j < mp.size(); j++) {
      vis2[mp[j]] = (vis[mp[j]] == 2 ? 1 : 0);
      vis[mp[j]] = 0;
      vis1[mp[j]] = 1;
    }
    int Ans1 = ans1;
    mp.clear();
    mp.push_back(i);
    ans1 = 1, vis[i] = 2;
    if (dfs(i, 1)) flag2 = 1;
    int Ans2 = ans1;
    for (int j = 0; j < mp.size(); j++) vis1[mp[j]] = 1;
    if (flag1 == 1 && flag2 == 1) {
      if (Ans1 < Ans2)
        ANS += Ans1;
      else {
        ANS += Ans2;
        for (int j = 0; j < mp.size(); j++)
          vis2[mp[j]] = (vis[mp[j]] == 2 ? 1 : 0);
      }
    } else if (flag1 == 1)
      ANS += Ans1;
    else if (flag2 == 1) {
      ANS += Ans2;
      for (int j = 0; j < mp.size(); j++)
        vis2[mp[j]] = (vis[mp[j]] == 2 ? 1 : 0);
    } else {
      ANS = 0x3f3f3f3f;
      break;
    }
    mp.clear();
  }
  if (ANS < ans) {
    for (int i = 1; i <= n; i++) vis3[i] = vis2[i], ans = ANS;
  }
  mp.clear();
  ANS = 0;
  memset(vis1, 0, sizeof(vis1)), memset(vis, 0, sizeof(vis)),
      memset(vis2, 0, sizeof(vis2));
  for (int i = 1; i <= n; i++) {
    if (vis1[i] == 1) continue;
    mp.push_back(i);
    ans1 = 0, vis[i] = 1;
    int flag1 = 0, flag2 = 0;
    if (dfs(i, 2)) flag1 = 1;
    for (int j = 0; j < mp.size(); j++) {
      vis2[mp[j]] = (vis[mp[j]] == 2 ? 1 : 0);
      vis[mp[j]] = 0;
      vis1[mp[j]] = 1;
    }
    int Ans1 = ans1;
    mp.clear();
    mp.push_back(i);
    ans1 = 1, vis[i] = 2;
    if (dfs(i, 2)) flag2 = 1;
    for (int j = 0; j < mp.size(); j++) vis1[mp[j]] = 1;
    int Ans2 = ans1;
    if (flag1 == 1 && flag2 == 1) {
      if (Ans1 < Ans2)
        ANS += Ans1;
      else {
        ANS += Ans2;
        for (int j = 0; j < mp.size(); j++)
          vis2[mp[j]] = (vis[mp[j]] == 2 ? 1 : 0);
      }
    } else if (flag1 == 1)
      ANS += Ans1;
    else if (flag2 == 1) {
      ANS += Ans2;
      for (int j = 0; j < mp.size(); j++)
        vis2[mp[j]] = (vis[mp[j]] == 2 ? 1 : 0);
    } else {
      ANS = 0x3f3f3f3f;
      break;
    }
    mp.clear();
  }
  if (ANS < ans) {
    for (int i = 1; i <= n; i++) vis3[i] = vis2[i], ans = ANS;
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int u, v;
  char s[2];
  for (int i = 0; i < m; i++) {
    scanf("%d%d%s", &u, &v, s);
    if (s[0] == 'B') {
      G[u].push_back(pair<int, int>{v, 1});
      G[v].push_back(pair<int, int>{u, 1});
    } else {
      G[u].push_back(pair<int, int>{v, 2});
      G[v].push_back(pair<int, int>{u, 2});
    }
  }
  ans = 0x3f3f3f3f;
  solve(n);
  if (ans == 0x3f3f3f3f)
    puts("-1");
  else {
    printf("%d\n", ans);
    for (int i = 1; i <= n; i++)
      if (vis3[i] == 1) printf("%d ", i);
    printf("\n");
  }
}
