#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int N, M;
vector<pair<int, int>> adj[MAXN];
int visit1[MAXN], visit2[MAXN];
int cnt1 = 0, ocnt1 = 0;
int cnt2 = 0, ocnt2 = 0;
bool flag1 = true, flag2 = true;
int order[MAXN];
int order_cnt = 1;
int ans[MAXN];
int c[MAXN];
vector<int> same[MAXN];
vector<int> diff[MAXN];
void dfs1(int here, int col) {
  if (col == 1)
    cnt1++;
  else
    ocnt1++;
  order[here] = order_cnt;
  for (auto &n : adj[here]) {
    int next = n.first;
    if (visit1[next] == -1) {
      visit1[next] = n.second == 1 ? 1 - col : col;
      dfs1(next, n.second == 1 ? 1 - col : col);
    } else if ((visit1[next] == col && n.second == 1) ||
               (visit1[next] != col && n.second == 0)) {
      flag1 = false;
    }
  }
}
void dfs2(int here, int col) {
  if (col == 1)
    cnt2++;
  else
    ocnt2++;
  for (auto &n : adj[here]) {
    int next = n.first;
    if (visit2[next] == -1) {
      visit2[next] = n.second == 1 ? col : 1 - col;
      dfs2(next, n.second == 1 ? col : 1 - col);
    } else if ((visit2[next] == col && 1 - n.second == 1) ||
               (visit2[next] != col && 1 - n.second == 0)) {
      flag2 = false;
    }
  }
}
int ret = 0;
int can = 0;
void dfs(int here, vector<int> clr[2], int color) {
  c[here] = color;
  clr[color].push_back(here);
  for (int i = 0; i < same[here].size(); i++) {
    int there = same[here][i];
    if (c[there] == -1)
      dfs(there, clr, color);
    else if (c[there] != color)
      can = 0;
  }
  for (int i = 0; i < diff[here].size(); i++) {
    int there = diff[here][i];
    if (c[there] == -1)
      dfs(there, clr, color ^ 1);
    else if (c[there] != (color ^ 1))
      can = 0;
  }
}
void print(vector<int> &copy) {
  printf("%d\n", copy.size());
  for (auto x : copy) {
    printf("%d ", x);
  }
}
int main() {
  memset(visit1, -1, sizeof visit1);
  memset(visit2, -1, sizeof visit2);
  scanf("%d%d", &N, &M);
  for (int m = 0; m < M; m++) {
    int u, v;
    char c;
    scanf("%d%d %c", &u, &v, &c);
    adj[u].push_back({v, c == 'R' ? 1 : 0});
    adj[v].push_back({u, c == 'R' ? 1 : 0});
  }
  int ccan[2];
  ccan[0] = 1;
  ccan[1] = 1;
  vector<int> ans[2];
  for (int color = 0; color < 2; color++) {
    memset(c, -1, sizeof(c));
    for (int j = 0; j < MAXN; j++) {
      diff[j].clear(), same[j].clear();
    }
    for (int j = 1; j <= N; j++) {
      for (auto x : adj[j]) {
        if (x.second == color) {
          same[x.first].push_back(j);
          same[j].push_back(x.first);
        } else {
          diff[x.first].push_back(j);
          diff[j].push_back(x.first);
        }
      }
    }
    for (int j = 1; j <= N; j++) {
      if (c[j] == -1) {
        can = 1;
        vector<int> temp[2];
        dfs(j, temp, 0);
        ccan[color] &= can;
        if (temp[1].size() < temp[0].size()) swap(temp[0], temp[1]);
        for (auto x : temp[0]) ans[color].push_back(x);
      }
    }
  }
  if (!ccan[0] && !ccan[1]) {
    printf("-1");
    exit(0);
  } else if (!ccan[0]) {
    print(ans[1]);
  } else if (!ccan[1]) {
    print(ans[0]);
  } else {
    if (ans[1].size() < ans[0].size()) swap(ans[0], ans[1]);
    print(ans[0]);
  }
  return 0;
}
