#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = (int)1e9 + 9;
const int MAXN = (int)3e5 + 7;
int n, m;
int a[MAXN];
int b[MAXN];
int c[MAXN];
bool used[MAXN];
int comp[MAXN];
int on[MAXN];
vector<int> g[MAXN];
vector<int> gd[MAXN];
vector<int> grev[MAXN];
int t(int x) { return x + x; }
int first(int x) { return (x + x) ^ 1; }
vector<int> order;
void dfs1(int v) {
  used[v] = true;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (!used[to]) dfs1(to);
  }
  order.push_back(v);
}
void dfs2(int v, int cl) {
  comp[v] = cl;
  for (size_t i = 0; i < grev[v].size(); ++i) {
    int to = grev[v][i];
    if (comp[to] == -1) dfs2(to, cl);
  }
}
int cc, sz;
vector<int> li;
void go(int x) {
  used[x] = 1;
  if (on[x]) cc++;
  sz++;
  li.push_back(x);
  for (auto to : gd[x])
    if (!used[to]) go(to);
}
vector<int> solve(int target) {
  for (int i = 0; i < n + n; i++) {
    g[i].clear();
    grev[i].clear();
  }
  order.clear();
  for (int i = 1; i <= m; i++) {
    if (c[i] == target) {
      g[first(a[i])].push_back(first(b[i]));
      g[t(b[i])].push_back(t(a[i]));
      g[t(a[i])].push_back(t(b[i]));
      g[first(b[i])].push_back(first(a[i]));
    } else {
      g[first(a[i])].push_back(t(b[i]));
      g[first(b[i])].push_back(t(a[i]));
      g[t(a[i])].push_back(first(b[i]));
      g[t(b[i])].push_back(first(a[i]));
    }
  }
  for (int i = 0; i < n + n; i++) {
    for (auto j : g[i]) {
      grev[j].push_back(i);
    }
  }
  memset(used, 0, sizeof used);
  for (int i = 0; i < n + n; i++) {
    if (!used[i]) dfs1(i);
  }
  memset(comp, -1, sizeof comp);
  for (int i = 0, j = 0; i < n + n; i++) {
    int v = order[n + n - i - 1];
    if (comp[v] == -1) dfs2(v, j++);
  }
  vector<int> no_sol;
  for (int i = 0; i < n + n; i++) no_sol.push_back(i);
  for (int i = 0; i < n; i++) {
    if (comp[i + i] == comp[i + i + 1]) {
      return no_sol;
    }
  }
  memset(on, 0, sizeof on);
  vector<int> cnt;
  for (int i = 0; i < n; i++) {
    if (comp[i + i] > comp[i + i + 1]) on[i] = 1;
  }
  memset(used, 0, sizeof used);
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      cc = 0;
      sz = 0;
      li.clear();
      go(i);
      int inv = 0;
      if (sz - cc < cc) {
        inv = 1;
      }
      for (auto it : li) {
        if (on[it] ^ inv) cnt.push_back(it);
      }
    }
  }
  return cnt;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    char ch;
    scanf("\n%d %d %c", &a[i], &b[i], &ch);
    a[i]--;
    b[i]--;
    c[i] = (ch == 'R');
  }
  for (int i = 1; i <= m; i++) {
    gd[a[i]].push_back(b[i]);
    gd[b[i]].push_back(a[i]);
  }
  vector<int> l = solve(0);
  vector<int> r = solve(1);
  if (l.size() < r.size()) swap(l, r);
  if (r.size() == n + n) {
    cout << -1;
    return 0;
  }
  printf("%d\n", r.size());
  for (auto it : r) printf("%d ", it + 1);
  return 0;
}
