#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[100005];
int mk[100005], vis[100005];
queue<int> q;
vector<int> now[2];
vector<int> ans[2];
vector<int> bk;
int bfs(int x, int f, int y, int id) {
  bk.clear();
  while (!q.empty()) q.pop();
  mk[x] = y;
  vis[x] = 1;
  if (mk[x]) now[y].push_back(x);
  q.push(x);
  bk.push_back(x);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto t : v[u]) {
      int to = t.first;
      int tp = t.second;
      int dif = abs(tp - f);
      if (mk[to] == -1) {
        mk[to] = abs(dif - mk[u]);
        if (mk[to]) now[y].push_back(to);
        vis[to] = 1;
        q.push(to);
        bk.push_back(to);
      } else if ((mk[to] + mk[u] + dif) % 2)
        return 0;
    }
  }
  return 1;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    char s[5];
    int a, b, x;
    for (int i = 1; i <= m; i++) {
      scanf("%d%d%s", &a, &b, s);
      if (s[0] == 'R') {
        v[a].push_back(make_pair(b, 0));
        v[b].push_back(make_pair(a, 0));
      } else {
        v[a].push_back(make_pair(b, 1));
        v[b].push_back(make_pair(a, 1));
      }
    }
    memset(mk, -1, sizeof(mk));
    int ps = -1, mx = 1e8;
    for (int i = 0; i <= 1; i++) {
      memset(vis, 0, sizeof(vis));
      int ff = 1, f = 0, num;
      for (int k = 1; k <= n; k++) {
        if (!vis[k]) {
          for (int j = 0; j <= 1; j++) {
            now[j].clear();
            f = bfs(k, i, j, num);
            ff = ff & f;
            for (auto x : bk) mk[x] = -1;
          }
          if (now[1].size() < now[0].size()) swap(now[0], now[1]);
          ans[i].insert(ans[i].end(), now[0].begin(), now[0].end());
        }
      }
      if (ff && ans[i].size() < mx) {
        mx = ans[i].size();
        ps = i;
      }
    }
    if (ps == -1)
      cout << -1 << endl;
    else {
      cout << ans[ps].size() << endl;
      for (auto x : ans[ps]) printf("%d ", x);
      printf("\n");
    }
  }
  return 0;
}
