#include <bits/stdc++.h>
using namespace std;
const int Max = 1e9 + 100;
const long long int MAX = 1e18 + 500;
const int sz = 2e5 + 100;
vector<pair<int, int> > ad[sz];
int mark[sz];
bool vis[sz];
vector<int> ZERO, ONE;
int one = 0, two = 0;
bool ok = false;
void DFS(int p, int col, int tar) {
  mark[p] = col;
  vis[p] = true;
  if (col == 1)
    ++one, ONE.push_back(p);
  else
    ++two, ZERO.push_back(p);
  for (auto xx : ad[p]) {
    if (vis[xx.first] == true) {
      if (xx.second == tar) {
        if (col != mark[xx.first]) ok = false;
      } else {
        if (col == mark[xx.first]) ok = false;
      }
    } else {
      if (xx.second == tar)
        DFS(xx.first, col, tar);
      else
        DFS(xx.first, col ^ 1, tar);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int a, b, c, i, j, k, q, p, x, y, ct, ct1, m, l, r, x1, y1, mn, h, sum1, in,
      z, mid, n, mx;
  char ch;
  double d;
  string str1, str2, str;
  bool bl, bl1;
  int t, cs = 1;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> p >> q >> ch;
    if (ch == 'R')
      ad[p].push_back({q, 0}), ad[q].push_back({p, 0});
    else
      ad[p].push_back({q, 1}), ad[q].push_back({p, 1});
  }
  vector<int> st[2];
  bool le[2];
  le[0] = le[1] = true;
  for (int tar = 0; tar <= 1; tar++) {
    memset(mark, 0, sizeof mark);
    memset(vis, false, sizeof vis);
    for (int i = 1; i <= n; i++) {
      ok = true;
      one = 0, two = 0;
      if (vis[i] == false) {
        ONE.clear();
        ZERO.clear();
        DFS(i, 0, tar);
        if (ok == false) le[tar] = false;
        if (one > two) {
          for (auto xx : ZERO) st[tar].push_back(xx);
        } else {
          for (auto xx : ONE) st[tar].push_back(xx);
        }
      }
    }
  }
  mx = Max;
  int id = -1;
  if (le[0] == true) mx = st[0].size(), id = 0;
  if (le[1] == true && mx > st[1].size()) mx = st[1].size(), id = 1;
  if (id == -1)
    cout << "-1\n";
  else {
    cout << st[id].size() << '\n';
    for (auto xx : st[id]) cout << xx << " ";
    cout << '\n';
  }
}
