#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 8;
int n, m, nedge;
int head[MAXN];
int vis[MAXN];
vector<int> divs[2];
struct edge {
  int u, v, c, nxt;
} edges[MAXN * 2];
void add_edge(int u, int v, int c) {
  edges[nedge].u = u;
  edges[nedge].v = v;
  edges[nedge].c = c;
  edges[nedge].nxt = head[u];
  head[u] = nedge++;
}
bool dfs(int u, int div, int c) {
  if (vis[u] != -1) {
    return vis[u] == div;
  }
  divs[div].push_back(u);
  vis[u] = div;
  for (int i = head[u]; i != -1; i = edges[i].nxt) {
    if (edges[i].c == c) {
      if (!dfs(edges[i].v, div, c)) return false;
    } else {
      if (!dfs(edges[i].v, div ^ 1, c)) return false;
    }
  }
  return true;
}
vector<int> solve(int color) {
  vector<int> ans;
  vector<int> tans;
  for (int i = 1; i <= n + 1; i++) {
    tans.push_back(-1);
  }
  memset(vis, -1, sizeof vis);
  for (int i = 1; i <= n; i++) {
    if (vis[i] == -1) {
      divs[0].clear();
      divs[1].clear();
      if (!dfs(i, 0, color)) {
        return tans;
      }
      int tmp = 0;
      if (divs[0].size() > divs[1].size()) tmp = 1;
      ans.insert(ans.end(), divs[tmp].begin(), divs[tmp].end());
    }
  }
  return ans;
}
int main() {
  while (~scanf("%d %d", &n, &m)) {
    memset(head, -1, sizeof head);
    nedge = 0;
    int u, v;
    char c;
    for (int i = 1; i <= m; i++) {
      scanf("%d %d  %c", &u, &v, &c);
      if (c == 'R') {
        add_edge(u, v, 1);
        add_edge(v, u, 1);
      } else {
        add_edge(u, v, 2);
        add_edge(v, u, 2);
      }
    }
    vector<int> ans1 = solve(1);
    vector<int> ans2 = solve(2);
    if (ans2.size() > n && ans1.size() > n) {
      printf("-1\n");
    } else {
      if (ans1.size() <= ans2.size()) {
        int tmp = ans1.size();
        printf("%d\n", tmp);
        for (int i = 0; i < ans1.size(); i++) {
          if (i != 0) printf(" ");
          printf("%d", ans1[i]);
        }
        printf("\n");
      } else {
        int tmp = ans2.size();
        printf("%d\n", tmp);
        for (int i = 0; i < ans2.size(); i++) {
          if (i != 0) printf(" ");
          printf("%d", ans2[i]);
        }
        printf("\n");
      }
    }
  }
  return 0;
}
