#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long maxn = 1e6 + 10, N = 500 + 10, SQRT = 300, base = 800287,
                mod = 1e9 + 7, INF = 1e9 + 1, lg = 23;
const long double eps = 1e-4;
long long n, m, color[maxn];
vector<pair<long long, long long> > edges[maxn];
vector<long long> vec1, vec2, v1, v2, tmp1, tmp2;
bitset<maxn> mark;
bool dfs1(long long v, long long c = 0) {
  bool res = 0;
  mark[v] = 1, color[v] = c;
  if (!c) {
    tmp1.push_back(v);
  } else {
    tmp2.push_back(v);
  }
  for (auto u : edges[v]) {
    long long val = c;
    if (!u.second) {
      val ^= 1;
    }
    if (!mark[u.first]) {
      res |= dfs1(u.first, val);
    } else {
      res |= (color[u.first] != val);
    }
  }
  return res;
}
bool dfs2(long long v, long long c = 0) {
  bool res = 0;
  mark[v] = 1, color[v] = c;
  if (!c) {
    tmp1.push_back(v);
  } else {
    tmp2.push_back(v);
  }
  for (auto u : edges[v]) {
    long long val = c;
    if (u.second) {
      val ^= 1;
    }
    if (!mark[u.first]) {
      res |= dfs2(u.first, val);
    } else {
      res |= (color[u.first] != val);
    }
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    long long x, y;
    char z;
    cin >> x >> y >> z;
    x--;
    y--;
    long long zz = (z == 'R' ? 0 : 1);
    edges[x].push_back({y, zz});
    edges[y].push_back({x, zz});
  }
  bool is1 = 0, is2 = 0;
  for (long long i = 0; i < n; ++i) {
    if (!mark[i]) {
      tmp1.clear();
      tmp2.clear();
      is1 |= dfs1(i);
      if ((long long)tmp1.size() > (long long)tmp2.size()) {
        tmp1.swap(tmp2);
      }
      vec1.insert(vec1.end(), tmp1.begin(), tmp1.end());
      vec2.insert(vec2.end(), tmp2.begin(), tmp2.end());
    }
  }
  mark.reset();
  for (long long i = 0; i < n; ++i) {
    if (!mark[i]) {
      tmp1.clear();
      tmp2.clear();
      is2 |= dfs2(i);
      if ((long long)tmp1.size() > (long long)tmp2.size()) {
        tmp1.swap(tmp2);
      }
      v1.insert(v1.end(), tmp1.begin(), tmp1.end());
      v2.insert(v2.end(), tmp2.begin(), tmp2.end());
    }
  }
  if (is1 && is2) {
    cout << -1 << '\n';
  } else {
    long long mn1 = (!is1 ? (long long)vec1.size() : INF),
              mn2 = (!is2 ? (long long)v1.size() : INF);
    long long ans = min(mn1, mn2);
    cout << ans << '\n';
    if (mn1 == ans) {
      for (auto u : vec1) {
        cout << u + 1 << ' ';
      }
    } else {
      for (auto u : v1) {
        cout << u + 1 << ' ';
      }
    }
    cout << '\n';
  }
}
