#include <bits/stdc++.h>
const int maxn = 100001;
const int maxm = 200001;
int n, m, s1, s2;
int st[maxn], pv[maxm], pl[maxm], tot;
bool pc[maxm], visit[2][maxn], col[2][maxn], visit2[2][maxn];
void side(int u, int v, bool c) {
  pv[++tot] = v;
  pc[tot] = c;
  pl[tot] = st[u];
  st[u] = tot;
}
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    getchar();
    char c = getchar();
    side(u, v, c == 'R');
    side(v, u, c == 'R');
  }
}
bool dfs(int c, int x) {
  visit[c][x] = true;
  s1++;
  s2 += col[c][x];
  for (int i = st[x]; i; i = pl[i]) {
    int v = pv[i];
    if (!visit[c][v]) {
      col[c][v] = pc[i] ^ col[c][x] ^ c;
      if (!dfs(c, v)) return false;
    } else if ((pc[i] ^ col[c][x] ^ col[c][v]) != c)
      return false;
  }
  return true;
}
void dfs2(int c, int x) {
  col[c][x] = !col[c][x];
  visit2[c][x] = true;
  for (int i = st[x]; i; i = pl[i])
    if (!visit2[c][pv[i]]) dfs2(c, pv[i]);
}
int solve(int c) {
  int ret = 0;
  for (int i = 1; i <= n; i++)
    if (!visit[c][i]) {
      s1 = s2 = 0;
      col[c][i] = true;
      if (!dfs(c, i)) return -1;
      if (s2 > s1 - s2) {
        s2 = s1 - s2;
        dfs2(c, i);
      }
      ret += s2;
    }
  return ret;
}
int main() {
  init();
  int ans, ans1 = solve(1), ans2 = solve(0);
  if (ans1 == -1 && ans2 == -1) {
    printf("-1\n");
    return 0;
  } else if (ans1 != -1 && ans2 == -1)
    ans = 1;
  else if (ans1 == -1 && ans2 != -1)
    ans = 0;
  else if (ans1 < ans2)
    ans = 1;
  else
    ans = 0;
  if (ans)
    printf("%d\n", ans1);
  else
    printf("%d\n", ans2);
  for (int i = 1; i <= n; i++)
    if (col[ans][i]) printf("%d ", i);
  return 0;
}
