#include <bits/stdc++.h>
const long long inf = 0x3f3f3f3f3f3f3f3LL;
const long long mod = (long long)1e9 + 7;
using namespace std;
template <class T, class T2>
void smin(T& a, T2 val) {
  if (a > val) a = val;
}
template <class T, class T2>
void smax(T& a, T2 val) {
  if (a < val) a = val;
}
const long long N = 2 * (long long)1e5 + 10;
long long n, m;
vector<array<long long, 2>> v[N];
long long vis[N];
vector<long long> component[2];
bool dfs(long long s, long long color, long long end_color) {
  if (vis[s] != -1) {
    ;
    return (vis[s] == color);
  }
  vis[s] = color;
  component[color].push_back(s);
  for (auto it : v[s]) {
    if (!dfs(it[0], (end_color == it[1]) ? color : 1 - color, end_color)) {
      return false;
    }
  }
  return true;
}
vector<long long> solve(long long color) {
  for (long long i = 0; i < n; ++i) {
    vis[i] = -1;
  }
  vector<long long> ans;
  for (long long i = 0; i < n; ++i) {
    if (vis[i] != -1) {
      continue;
    }
    component[0].clear();
    component[1].clear();
    if (dfs(i, 0, color) == false) {
      ;
      ans.assign(n + 1, -1);
      break;
    }
    if ((long long)(component[0].size()) > (long long)(component[1].size())) {
      swap(component[0], component[1]);
    }
    ans.insert(ans.end(), component[0].begin(), component[0].end());
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    char col;
    long long x, y;
    cin >> x >> y >> col;
    --x, --y;
    v[x].push_back({y, col == 'R'});
    v[y].push_back({x, col == 'R'});
  }
  auto A = solve(0);
  auto B = solve(1);
  if ((long long)(B.size()) < (long long)(A.size())) {
    swap(A, B);
  }
  if ((long long)(A.size()) > n) {
    cout << -1 << '\n';
    return 0;
  }
  cout << (long long)(A.size()) << '\n';
  for (auto it : A) {
    cout << it + 1 << " ";
  }
  return 0;
}
