#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 7;
const int M = 107;
const int mod = 998244353;
const int inf = 1e9 + 7;
const double pi = acos(-1);
const int maxn = N * 2;
const double PI = acos(-1);
int n, m;
vector<pair<int, int> > adj[N];
int visited[N];
int currentSet = 0;
int dp[2][N];
int currentRoot;
long long ans[2];
stack<int> st;
void DFS(int u) {
  dp[currentSet][currentRoot] += visited[u];
  st.push(u);
  for (int j = (0); j < (adj[u].size()); j++) {
    int v = adj[u][j].first;
    int c = adj[u][j].second;
    if (visited[u] == 1) c ^= 1;
    if (visited[v] == 2) {
      visited[v] = (c != currentSet);
      DFS(v);
    } else {
      int nw = visited[u] ^ visited[v];
      int t = adj[u][j].second;
      if (nw) t ^= 1;
      if (t != currentSet) {
        dp[currentSet][currentRoot] = -inf;
      }
    }
  }
}
vector<pair<int, int> > trace[2];
void solve() {
  cin >> n >> m;
  for (int i = (0); i < (m); i++) {
    int u, v;
    char c;
    scanf("%d %d %c", &u, &v, &c);
    int t = (c == 'R');
    adj[u].push_back(make_pair(v, t));
    adj[v].push_back(make_pair(u, t));
  }
  for (currentSet = 0; currentSet < 2; currentSet++) {
    for (int i = (1); i < (n + 1); i++) visited[i] = 2;
    ans[currentSet] = 0;
    for (int i = 1; i <= n; i++) {
      if (visited[i] == 2) {
        int mn = inf;
        int type = 0;
        for (int nowSet = 0; nowSet < 2; nowSet++) {
          while (!st.empty()) st.pop();
          visited[i] = nowSet;
          currentRoot = i;
          dp[currentSet][currentRoot] = 0;
          DFS(i);
          if (dp[currentSet][currentRoot] >= 0 &&
              dp[currentSet][currentRoot] < mn) {
            mn = dp[currentSet][currentRoot];
            type = nowSet;
          }
          if (nowSet == 0) {
            while (!st.empty()) {
              visited[st.top()] = 2;
              st.pop();
            }
          }
        }
        trace[currentSet].push_back(make_pair(currentRoot, type));
        if (mn >= inf) {
          ans[currentSet] = -inf;
        } else {
          ans[currentSet] += mn;
        }
      }
    }
  }
  if (ans[0] < 0 && ans[1] < 0) {
    puts("-1");
    return;
  }
  if (ans[0] < 0)
    currentSet = 1;
  else if (ans[1] < 0)
    currentSet = 0;
  else if (ans[0] < ans[1])
    currentSet = 0;
  else
    currentSet = 1;
  while (!st.empty()) st.pop();
  for (int i = 1; i <= n; i++) {
    visited[i] = 2;
  }
  for (int j = (0); j < (trace[currentSet].size()); j++) {
    int u = trace[currentSet][j].first;
    int type = trace[currentSet][j].second;
    visited[u] = type;
    DFS(u);
  }
  cout << ans[currentSet] << "\n";
  for (int i = 1; i <= n; i++) {
    if (visited[i] == 1) printf("%d ", i);
  }
}
int main() {
  int T = 1;
  for (int i = (1); i < (T + 1); i++) {
    solve();
  }
}
