#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 28;
const long long LINF = 1ll << 61;
inline long long getnum() {
  register long long r = 0;
  register bool ng = 0;
  register char c;
  c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') ng = 1, c = getchar();
  while (c != ' ' && c != '\n') r = r * 10 + c - '0', c = getchar();
  if (ng) r = -r;
  return r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline void putsp() { putchar(' '); }
inline void putendl() { putchar('\n'); }
inline char mygetchar() {
  register char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
int f[200111];
int sz[200111];
bool vis[200111];
bool mk[200111];
int gf(int x) { return f[x] == x ? x : f[x] = gf(f[x]); }
int n, m;
pair<pair<int, int>, char> edge[100111];
vector<int> tv;
int solve(char c) {
  for (int i = 1; i <= 2 * n; i++) f[i] = i;
  memset(sz, 0, sizeof(sz));
  for (int i = 1; i <= m; i++) {
    int x = edge[i].first.first, y = edge[i].first.second;
    int xx = edge[i].first.first + n, yy = edge[i].first.second + n;
    if (edge[i].second == c)
      f[gf(x)] = gf(y), f[gf(xx)] = gf(yy);
    else
      f[gf(x)] = gf(yy), f[gf(xx)] = gf(y);
  }
  for (int i = 1; i <= n; i++)
    if (gf(i) == gf(i + n)) return n + 1;
  int ans = 0;
  for (int i = 1; i <= n; i++) sz[f[i]]++;
  memset(vis, 0, sizeof(vis));
  memset(mk, 0, sizeof(mk));
  tv.clear();
  for (int i = 1; i <= n; i++) {
    if (vis[f[i]]) continue;
    vis[f[i]] = vis[f[i + n]] = 1;
    if (sz[f[i]] < sz[f[i + n]]) {
      mk[f[i]] = 1;
      ans += sz[f[i]];
    } else {
      mk[f[i + n]] = 1;
      ans += sz[f[i + n]];
    }
  }
  for (int i = 1; i <= n; i++)
    if (mk[f[i]]) tv.push_back(i);
  return ans;
}
int main() {
  n = getnum(), m = getnum();
  for (int i = 1; i <= m; i++) {
    edge[i].first.first = getnum(), edge[i].first.second = getnum();
    edge[i].second = mygetchar();
  }
  int ans1 = solve('R');
  int ans2 = solve('B');
  if (ans1 > n && ans2 > n)
    puts("-1");
  else {
    if (ans1 < ans2)
      solve('R');
    else
      solve('B');
    putnum(tv.size()), putendl();
    for (int i = 0; i < tv.size(); i++) putnum(tv[i]), putsp();
  }
  return 0;
}
