#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int SIZ_TREE = 3e5 + 10;
int n, m;
struct Node {
  int u, v;
  Node(int U = 0, int V = 0) {
    u = U, v = V;
    if (u < v) swap(u, v);
  }
  bool operator<(const Node A) const {
    if (u < A.u || (u == A.u && v < A.v)) return true;
    return false;
  }
};
vector<int> f[N], ans[2];
vector<Node> edg;
map<Node, bool> col;
bool v[N], opr[N], flag1, flag2, add[N];
int cnt_p, cnt_opr;
void init() {
  char s;
  int x, y;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    while ((s = getchar()) == ' ')
      ;
    f[y].push_back(x);
    f[x].push_back(y);
    edg.push_back(Node(x, y));
    col[Node(x, y)] = (s == 'R' ? false : true);
  }
}
bool dfs(int x) {
  v[x] = true;
  cnt_p++;
  cnt_opr += opr[x];
  for (int i = 0; i < f[x].size(); i++) {
    int y = f[x][i];
    if (v[y]) {
      if ((col[Node(x, y)] ^ opr[x] ^ opr[y]) == true) return false;
    } else {
      opr[y] = col[Node(x, y)] ^ opr[x];
      if (!dfs(y)) return false;
    }
  }
  return true;
}
void add_ans(int x, bool s1, int s2) {
  if (add[x]) return;
  opr[x] ^= s1;
  add[x] = true;
  if (opr[x]) ans[s2].push_back(x);
  for (int i = 0; i < f[x].size(); i++) add_ans(f[x][i], s1, s2);
}
bool solve(int sign) {
  memset(opr, 0, sizeof(opr));
  memset(v, 0, sizeof(v));
  memset(add, 0, sizeof(add));
  for (int i = 1; i <= n; i++)
    if (!v[i]) {
      cnt_opr = cnt_p = 0;
      if (!dfs(i)) return false;
      add_ans(i, (cnt_opr * 2 > cnt_p), sign);
    }
  return true;
}
void print(int s) {
  printf("%d\n", ans[s].size());
  for (int i = 0; i < ans[s].size(); i++) printf("%d ", ans[s][i]);
  printf("\n");
}
void work() {
  flag1 = solve(0);
  for (int i = 0; i < edg.size(); i++) col[edg[i]] = (!col[edg[i]]);
  flag2 = solve(1);
  if (!flag1 && !flag2)
    printf("-1\n");
  else if (flag1 && !flag2)
    print(0);
  else if (!flag1 && flag2)
    print(1);
  else if (ans[0].size() < ans[1].size())
    print(0);
  else
    print(1);
}
int main() {
  init();
  work();
  return 0;
}
