#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
vector<pair<int, int> > col_G[(int)(2e5 + 500)];
int n, m;
int vis[(int)(2e5 + 500)];
vector<int> part[3];
int dfs(int x, int c, int req) {
  if (vis[x] != -1) {
    return vis[x] == c;
  }
  vis[x] = c;
  part[c].push_back(x);
  int ok = 1;
  for (int i = 0; i < col_G[x].size(); i++) {
    int to = col_G[x][i].first;
    int col = col_G[x][i].second;
    if (col != req)
      ok &= dfs(to, 1 - c, req);
    else
      ok &= dfs(to, c, req);
  }
  return ok;
}
vector<int> go(int x) {
  memset(vis, -1, sizeof(vis));
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == -1) {
      part[0].clear();
      part[1].clear();
      if (dfs(i, 0, x)) {
        if (part[0].size() > part[1].size()) {
          part[0] = part[1];
        }
        ans.insert(ans.end(), part[0].begin(), part[0].end());
      } else {
        for (int i = 0; i < n + 1; i++) {
          ans.push_back(-1);
        }
        return ans;
      }
    }
  }
  return ans;
}
void solve() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y, col;
    char c;
    scanf("%d", &x);
    scanf("%d", &y);
    cin >> c;
    if (c == 'R')
      col = 0;
    else
      col = 1;
    col_G[x].push_back(make_pair(y, col));
    col_G[y].push_back(make_pair(x, col));
  }
  vector<int> a1 = go(0);
  vector<int> a2 = go(1);
  if (a1.size() > a2.size()) a1 = a2;
  if (a1.size() > n)
    printf("-1");
  else {
    printf("%d", (int)a1.size());
    printf("\n");
    for (int i = 0; i < a1.size(); i++) {
      printf("%d", a1[i]);
      printf(" ");
    }
  }
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
