#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double EPS = 1e-9;
const long long mod = 1000000007ll;
const int maxn = (int)100000 + 10;
int n, m;
vector<pair<int, int>> adj[maxn];
bool vis[maxn];
int done[maxn], cho[maxn], color;
vector<int> curComp1, curComp2, ret, curColor, resetComp;
int dfsComp(int u, vector<int> &curComp) {
  resetComp.push_back(u);
  int ret = 0;
  done[u] = 1;
  vis[u] = true;
  for (auto v : adj[u])
    if (done[v.first] == -1) {
      if ((cho[u] == 0 && v.second != color) ||
          (cho[u] == 1 && v.second == color)) {
        cho[v.first] = 1;
        if (dfsComp(v.first, curComp) == -1) return -1;
        curComp.push_back(v.first);
      } else if ((cho[u] == 0 && v.second == color) ||
                 (cho[u] == 1 && v.second != color)) {
        cho[v.first] = 0;
        if (dfsComp(v.first, curComp) == -1) return -1;
      }
    } else if ((cho[u] == 0 && v.second != color && cho[v.first] == 0) ||
               (cho[u] == 0 && v.second == color && cho[v.first] == 1) ||
               (cho[u] == 1 && v.second != color && cho[v.first] == 1) ||
               (cho[u] == 1 && v.second == color && cho[v.first] == 0))
      return -1;
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  char c[2];
  for (int i = 0; i < (int)(m); ++i) {
    scanf("%d%d", &u, &v), scanf("%s", c);
    adj[u].push_back({v, (c[0] == 'B') ? 1 : 0});
    adj[v].push_back({u, (c[0] == 'B') ? 1 : 0});
  }
  color = 0;
  int ans = -1;
  for (; color < 2; color++) {
    memset(vis, 0, sizeof(vis));
    memset(done, -1, sizeof(done));
    int cur = 0;
    curColor.clear();
    for (int i = 1; i <= n; i++)
      if (vis[i] == false) {
        resetComp.clear();
        cho[i] = 0;
        curComp1.clear();
        int t = dfsComp(i, curComp1);
        for (int it : resetComp) done[it] = -1;
        curComp2.clear();
        cho[i] = 1;
        curComp2.push_back(i);
        int t2 = dfsComp(i, curComp2);
        if (t == -1 && t2 == -1) {
          cur = -1;
          break;
        }
        if (curComp1.size() < curComp2.size())
          curColor.insert(curColor.end(), curComp1.begin(), curComp1.end());
        else
          curColor.insert(curColor.end(), curComp2.begin(), curComp2.end());
        cur += min(curComp1.size(), curComp2.size());
      }
    if (cur == -1) continue;
    if (ans == -1 || cur < ans) ans = cur, ret = curColor;
  }
  printf("%d\n", ans);
  for (int i : ret) printf("%d ", i);
}
