#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238463;
const long long mod = 1000000007;
const long long mod2 = 10000019;
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U> &l, const std::pair<T, U> &r) {
  return {l.first + r.first, l.second + r.second};
}
struct E {
  int x;
  int y;
  int z;
};
bool cmpf(E &a1, E &a2) {
  if (a1.x != a2.x) return a1.x < a2.x;
  if (a1.y != a2.y) return a1.y < a2.y;
  return a1.z < a2.z;
}
long long gcd(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return gcd(b, a % b);
}
const int nn = 100001;
vector<int> ad[nn], rr[nn], bb[nn];
int cnt, mp[nn], cl[nn];
vector<int> tt[nn], x1, x2, res;
int n, m;
void dfs(int a) {
  mp[a] = cnt;
  tt[cnt].push_back(a);
  for (auto b : rr[a])
    if (!mp[b]) dfs(b);
}
bool clr(int a, int x) {
  cl[a] = x;
  if (x == 1)
    x1.push_back(a);
  else
    x2.push_back(a);
  bool ret = 1;
  for (auto b : ad[a]) {
    if (cl[b] == cl[a]) return 0;
    if (!cl[b]) ret = ret && clr(b, 3 - x);
  }
  return ret;
}
int cal() {
  for (int i = (1); i <= (n); ++i)
    if (!mp[i]) ++cnt, dfs(i);
  for (int i = (1); i <= (n); ++i)
    for (auto j : bb[i]) {
      if (mp[i] == mp[j]) return -1;
      ad[mp[i]].push_back(mp[j]);
      ad[mp[j]].push_back(mp[i]);
    }
  for (int i = (1); i <= (cnt); ++i)
    if (!cl[i]) {
      x1.clear();
      x2.clear();
      if (!clr(i, 1)) return -1;
      int a1 = 0, a2 = 0;
      for (auto a : x1) a1 += tt[a].size();
      for (auto a : x2) a2 += tt[a].size();
      if (a1 < a2) {
        for (auto b : x1) res.insert(res.end(), tt[b].begin(), tt[b].end());
      } else {
        for (auto b : x2) res.insert(res.end(), tt[b].begin(), tt[b].end());
      }
    }
  return res.size();
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (m); i++) {
    int a, b;
    char c;
    scanf("%d %d %c", &a, &b, &c);
    if (c == 'R') {
      rr[a].push_back(b);
      rr[b].push_back(a);
    } else {
      bb[a].push_back(b);
      bb[b].push_back(a);
    }
  }
  int ans1 = cal();
  vector<int> res1 = res;
  res.clear();
  for (int i = (1); i <= (nn); ++i) ad[i].clear(), tt[i].clear();
  memset(cl, 0, sizeof cl);
  memset(mp, 0, sizeof mp);
  cnt = 0;
  for (int i = (1); i <= (nn); ++i) swap(rr[i], bb[i]);
  int ans2 = cal();
  vector<int> res2 = res;
  if (ans1 == -1 || (ans2 != -1 && ans1 > ans2)) {
    swap(ans1, ans2);
    swap(res1, res2);
  }
  cout << ans1 << endl;
  if (ans1 != -1) {
    for (auto x : res1) cout << x << " ";
    cout << endl;
  }
}
