#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
struct {
  int t, c, nxt;
} E[N * 2];
int n, m, Es, adj[N], cg[N];
bool vis[N];
vector<int> lis, S[2], ans[2];
void AddEdge(int s, int t, int color) {
  E[Es].t = t;
  E[Es].c = color;
  E[Es].nxt = adj[s];
  adj[s] = Es++;
}
void DFS(int cur, int color, int tp) {
  vis[cur] = true;
  lis.push_back(cur);
  for (int j = adj[cur]; j >= 0; j = E[j].nxt) {
    if (vis[E[j].t]) continue;
    if ((cg[cur] ^ E[j].c) == color) {
      cg[E[j].t] = 0;
      DFS(E[j].t, color, tp);
    } else {
      cg[E[j].t] = 1;
      S[tp].push_back(E[j].t);
      DFS(E[j].t, color, tp);
    }
  }
}
int solve(int cur, int color, int tp) {
  cg[cur] = tp;
  if (tp == 1) S[tp].push_back(cur);
  DFS(cur, color, tp);
  for (int k = 0; k < (lis.size()); k++) {
    int cur = lis[k];
    for (int j = adj[cur]; j >= 0; j = E[j].nxt)
      if ((cg[cur] ^ cg[E[j].t] ^ E[j].c) != color) {
        if (tp == 0) {
          for (int i = 0; i < (lis.size()); i++) vis[lis[i]] = false;
        }
        lis.clear();
        return 0x3f3f3f3f;
      }
  }
  if (tp == 0) {
    for (int i = 0; i < (lis.size()); i++) vis[lis[i]] = false;
  }
  lis.clear();
  return S[tp].size();
}
int painting(int color) {
  for (int i = 1; i <= (n); i++)
    if (!vis[i]) {
      int t1 = solve(i, color, 0);
      int t2 = solve(i, color, 1);
      if (t1 <= t2) {
        if (t1 == 0x3f3f3f3f) {
          S[0].clear();
          S[1].clear();
          return 0x3f3f3f3f;
        }
        for (int j = 0; j < (S[0].size()); j++) ans[color].push_back(S[0][j]);
      } else {
        for (int j = 0; j < (S[1].size()); j++) ans[color].push_back(S[1][j]);
      }
      S[0].clear();
      S[1].clear();
    }
  return ans[color].size();
}
int main() {
  memset(adj, -1, sizeof(adj));
  scanf("%d %d\n", &n, &m);
  for (int i = 1; i <= (m); i++) {
    int u, v;
    char ch;
    scanf("%d %d %c\n", &u, &v, &ch);
    AddEdge(u, v, ch == 'R');
    AddEdge(v, u, ch == 'R');
  }
  int t1 = painting(0);
  memset(vis, false, sizeof(vis));
  int t2 = painting(1);
  if (t1 <= t2) {
    if (t1 == 0x3f3f3f3f) {
      printf("-1\n");
      return 0;
    }
    printf("%d\n", ans[0].size());
    for (int i = 0; i < (ans[0].size()); i++) printf("%d ", ans[0][i]);
    printf("\n");
  } else {
    printf("%d\n", ans[1].size());
    for (int i = 0; i < (ans[1].size()); i++) printf("%d ", ans[1][i]);
    printf("\n");
  }
  return 0;
}
