#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 1e5 + 10;
struct node {
  int v, c;
  node(){};
  node(int V, int C) {
    v = V;
    c = C;
  }
};
struct fuck {
  int u, v, c;
  fuck(){};
  fuck(int U, int V, int C) {
    u = U;
    v = V;
    c = C;
  }
};
vector<node> G[N];
vector<fuck> edge;
int n, m, FinalC, book[N], type, ans[2] = {0, 0}, chos[N], vis[N], flag = 1,
                                 cnt = 0, Flag[2] = {1, 1};
vector<int> T[2];
vector<int> now1;
vector<int> now2;
vector<int> getp;
void dfs(int u, bool IsChos) {
  chos[u] = IsChos;
  if (chos[u] && type == 0) now1.push_back(u);
  if (chos[u] && type == 1) now2.push_back(u);
  cnt += chos[u];
  getp.push_back(u);
  vis[u] = 1;
  book[u] = 1;
  int siz = G[u].size();
  bool nxtc;
  for (int v, i = 0; i < siz; i++) {
    v = G[u][i].v;
    if (vis[v]) {
      if (FinalC == G[u][i].c && chos[u] != chos[v]) flag = 0;
      if (FinalC != G[u][i].c && chos[u] == chos[v]) flag = 0;
      continue;
    }
    if (FinalC == G[u][i].c)
      nxtc = IsChos;
    else
      nxtc = !IsChos;
    dfs(v, nxtc);
  }
}
void init() {
  memset(chos, 0, sizeof(chos));
  memset(vis, 0, sizeof(chos));
  flag = 1;
  cnt = 0;
}
void init2() {
  for (int i = 0, siz = getp.size(); i < siz; i++)
    chos[getp[i]] = vis[getp[i]] = 0;
  flag = 1;
  cnt = 0;
}
void Fuck() {
  init();
  for (int i = 1; i <= n; i++)
    if (!book[i]) {
      int cnt1 = 0, cnt2 = 0, flag1 = 0, flag2 = 0;
      type = 0;
      now1.clear();
      now2.clear();
      flag = 1;
      cnt = 0;
      getp.clear();
      dfs(i, 0);
      cnt1 = cnt;
      flag1 = flag;
      init2();
      type = 1;
      dfs(i, 1);
      cnt2 = cnt;
      flag2 = flag;
      if (!flag1 && !flag2) {
        Flag[FinalC] = 0;
        break;
      }
      if (flag1 && !flag2) {
        ans[FinalC] += cnt1;
        for (int i = 0, siz = now1.size(); i < siz; i++)
          T[FinalC].push_back(now1[i]);
      }
      if (!flag1 && flag2) {
        ans[FinalC] += cnt2;
        for (int i = 0, siz = now2.size(); i < siz; i++)
          T[FinalC].push_back(now2[i]);
      }
      if (flag1 && flag2) {
        if (cnt1 < cnt2) {
          ans[FinalC] += cnt1;
          for (int i = 0, siz = now1.size(); i < siz; i++)
            T[FinalC].push_back(now1[i]);
        } else {
          ans[FinalC] += cnt2;
          for (int i = 0, siz = now2.size(); i < siz; i++)
            T[FinalC].push_back(now2[i]);
        }
      }
      now1.clear();
      now2.clear();
      getp.clear();
    }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    char c;
    c = getchar();
    G[u].push_back(node(v, (c == 'B') ? 1 : 0));
    G[v].push_back(node(u, (c == 'B') ? 1 : 0));
    edge.push_back(fuck(u, v, (c == 'B') ? 1 : 0));
  }
  FinalC = 0;
  Fuck();
  if (!Flag[0]) ans[0] = 1e5 + 10;
  memset(book, 0, sizeof(book));
  FinalC = 1;
  Fuck();
  if (!Flag[1]) ans[1] = 1e5 + 10;
  if (Flag[0] && Flag[1]) {
    if (ans[0] < ans[1]) {
      cout << ans[0] << endl;
      for (int i = 0, siz = T[0].size(); i < siz; i++) cout << T[0][i] << ' ';
    } else {
      cout << ans[1] << endl;
      for (int i = 0, siz = T[1].size(); i < siz; i++) cout << T[1][i] << ' ';
    }
    return 0;
  } else if (Flag[0] && !Flag[1]) {
    cout << ans[0] << endl;
    for (int i = 0, siz = T[0].size(); i < siz; i++) cout << T[0][i] << ' ';
  } else if (!Flag[0] && Flag[1]) {
    cout << ans[1] << endl;
    for (int i = 0, siz = T[1].size(); i < siz; i++) cout << T[1][i] << ' ';
  } else
    return 0 * printf("-1");
}
