#include <bits/stdc++.h>
using namespace std;
struct node {
  int num, next;
  char d;
};
node e[200011];
int edge[100011];
int taile;
void add(int xx, int yy, char d) {
  e[taile].num = yy;
  e[taile].d = d;
  e[taile].next = edge[xx];
  edge[xx] = taile++;
}
int n, m;
int ans;
vector<int> ans0[2];
vector<int> ansa;
vector<int> fin_ans0;
int col[100011];
int num[2];
bool dfs(int now, char dd) {
  int i;
  for (i = edge[now]; i != -1; i = e[i].next) {
    if (col[e[i].num] == -1) {
      col[e[i].num] = (e[i].d == dd) ? col[now] : 1 - col[now];
      num[col[e[i].num]]++;
      ans0[col[e[i].num]].push_back(e[i].num);
      if (dfs(e[i].num, dd) == false) return false;
    } else {
      if (((col[e[i].num] == col[now]) ^ (e[i].d == dd))) {
        return false;
      }
    }
  }
  return true;
}
int fin_ans;
int main() {
  int i, j, k;
  int xx, yy;
  char d;
  scanf("%d %d", &n, &m);
  taile = 1;
  memset(edge, -1, sizeof(edge));
  for (i = 1; i <= m; i++) {
    scanf("%d %d %c", &xx, &yy, &d);
    add(xx, yy, d);
    add(yy, xx, d);
  }
  fin_ans = 0x3f3f3f3f;
  ansa.clear();
  ans = 0;
  memset(col, -1, sizeof(col));
  for (i = 1; i <= n; i++) {
    if (col[i] == -1) {
      col[i] = 0;
      num[0] = 1;
      num[1] = 0;
      ans0[0].clear();
      ans0[1].clear();
      ans0[0].push_back(i);
      if (dfs(i, 'R') == false) {
        break;
      }
      if (num[0] <= num[1]) {
        ans += num[0];
        for (j = 0; j < ans0[0].size(); j++) {
          ansa.push_back(ans0[0][j]);
        }
      } else {
        ans += num[1];
        for (j = 0; j < ans0[1].size(); j++) {
          ansa.push_back(ans0[1][j]);
        }
      }
    }
  }
  if (i > n) {
    fin_ans = ans;
    fin_ans0 = ansa;
  }
  ans = 0;
  ansa.clear();
  memset(col, -1, sizeof(col));
  for (i = 1; i <= n; i++) {
    if (col[i] == -1) {
      col[i] = 0;
      num[0] = 1;
      num[1] = 0;
      ans0[0].clear();
      ans0[1].clear();
      ans0[0].push_back(i);
      if (dfs(i, 'B') == false) {
        break;
      }
      if (num[0] <= num[1]) {
        ans += num[0];
        for (j = 0; j < ans0[0].size(); j++) {
          ansa.push_back(ans0[0][j]);
        }
      } else {
        ans += num[1];
        for (j = 0; j < ans0[1].size(); j++) {
          ansa.push_back(ans0[1][j]);
        }
      }
    }
  }
  if (i > n) {
    if (fin_ans > ans) {
      fin_ans = ans;
      fin_ans0 = ansa;
    }
  }
  if (fin_ans != 0x3f3f3f3f) {
    cout << fin_ans << endl;
  } else {
    cout << -1 << endl;
    return 0;
  }
  if (fin_ans > 0) {
    for (i = 0; i < fin_ans0.size() - 1; i++) {
      cout << fin_ans0[i] << ' ';
    }
    cout << fin_ans0[i] << endl;
  }
  return 0;
}
