#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 100001;
vector<int> e[maxn], w[maxn], res;
bool vis[maxn], ok, heads[maxn];
short flip[maxn];
int COLOR, ans, dp[maxn][2][2];
void dfs(int u, short toFlip) {
  flip[u] = toFlip;
  vis[u] = true;
  ans += toFlip;
  for (int i = 0; i < e[u].size(); ++i) {
    int eWt = toFlip ^ w[u][i];
    int v = e[u][i];
    if (!vis[v]) {
      if (eWt != COLOR)
        dfs(v, 1);
      else
        dfs(v, 0);
    }
    int totFlips = (flip[u] + flip[v]) & 1;
    if ((totFlips ^ w[u][i]) != COLOR) {
      ok = false;
    }
  }
}
int main() {
  int n, m, x, y, u, v, wt;
  bool sol = 0;
  char c;
  cin >> n >> m;
  while (m--) {
    cin >> x >> y >> c;
    e[x].emplace_back(y);
    e[y].emplace_back(x);
    wt = (c == 'B');
    w[x].emplace_back(wt);
    w[y].emplace_back(wt);
  }
  for (int i = 0; i < maxn; ++i) {
    for (int j : {0, 1}) {
      for (int k : {0, 1}) dp[i][j][k] = n + 1;
    }
  }
  for (int COL : {0, 1}) {
    COLOR = COL;
    for (int FLIP : {0, 1}) {
      fill(vis + 1, vis + n + 1, false);
      fill(flip + 1, flip + n + 1, 0);
      for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
          ok = true;
          ans = 0;
          heads[i] = true;
          dfs(i, FLIP);
          if (ok) {
            dp[i][COLOR][FLIP] = min(dp[i][COLOR][FLIP], ans);
          }
        }
      }
    }
  }
  int res = n + 1;
  int sameCol = 0;
  for (int COLOR : {0, 1}) {
    bool isCol = true;
    ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (heads[i]) {
        int add = min(dp[i][COLOR][0], dp[i][COLOR][1]);
        if (add == n + 1) {
          isCol = false;
          break;
        }
        ans += add;
      }
    }
    if (isCol && ans < res) {
      res = ans;
      sameCol = COLOR;
    }
  }
  if (res == n + 1) {
    cout << "-1";
  } else {
    fill(vis + 1, vis + n + 1, false);
    fill(flip + 1, flip + n + 1, 0);
    COLOR = sameCol;
    for (int i = 1; i <= n; ++i) {
      if (heads[i]) {
        if (dp[i][sameCol][0] < dp[i][sameCol][1]) {
          dfs(i, 0);
        } else {
          dfs(i, 1);
        }
      }
    }
    cout << res << "\n";
    for (int i = 1; i <= n; ++i) {
      if (flip[i]) cout << i << " ";
    }
  }
  return 0;
}
