#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct Edge {
  int u, v, c;
} edge[maxn];
int f[maxn];
int num[maxn];
vector<int> G[maxn];
int idx[maxn];
vector<int> vp, vq;
bool vis[maxn];
int findset(int x) {
  if (x == f[x]) return x;
  return f[x] = findset(f[x]);
}
bool dfs(int u, int c, int& cp, int& cq) {
  idx[u] = c;
  if (c == 1) {
    cp += num[u];
    vp.push_back(u);
  } else {
    cq += num[u];
    vq.push_back(u);
  }
  for (int& v : G[u]) {
    if (!idx[v]) {
      if (!dfs(v, 3 - c, cp, cq)) return false;
    } else if (idx[v] != 3 - c)
      return false;
  }
  return true;
}
int solve(int n, int m, int id) {
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    num[i] = 1;
    G[i].clear();
    idx[i] = 0;
    vis[i] = false;
  }
  for (int i = 1; i <= m; i++) {
    Edge& e = edge[i];
    if (e.c == id) {
      int x = findset(e.u);
      int y = findset(e.v);
      if (x != y) {
        f[x] = y;
        num[y] += num[x];
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    Edge& e = edge[i];
    if (e.c != id) {
      int x = findset(e.u);
      int y = findset(e.v);
      G[x].push_back(y);
      G[y].push_back(x);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (f[i] == i && !idx[i]) {
      int cp = 0, cq = 0;
      vp.clear();
      vq.clear();
      if (!dfs(i, 1, cp, cq)) return -1;
      if (cp < cq) {
        for (int& j : vp) vis[j] = true;
        ans += cp;
      } else {
        for (int& j : vq) vis[j] = true;
        ans += cq;
      }
    }
  }
  return ans;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) f[i] = i;
  char s[2];
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%s", &edge[i].u, &edge[i].v, s);
    edge[i].c = s[0] == 'R' ? 0 : 1;
  }
  int ans = 1e9, id = -1;
  for (int i = 0; i <= 1; i++) {
    int val = solve(n, m, i);
    if (val >= 0 && val < ans) {
      ans = val;
      id = i;
    }
  }
  if (id < 0)
    printf("-1\n");
  else {
    printf("%d\n", ans);
    solve(n, m, id);
    for (int i = 1; i <= n; i++) {
      if (vis[findset(i)]) printf("%d ", i);
    }
    printf("\n");
  }
  return 0;
}
