#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[100005];
int a[100005], b[100005];
char s[2];
int vis[100005];
vector<int> com;
bool dfs(int u, int cc) {
  com.push_back(u);
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first, c = g[u][i].second;
    if (vis[v]) {
      if (c == cc) {
        if (vis[v] != vis[u]) return 0;
      } else {
        if (vis[v] == vis[u]) return 0;
      }
      continue;
    }
    if (c == cc) {
      vis[v] = vis[u];
      if (!dfs(v, cc)) return 0;
    } else {
      vis[v] = 3 - vis[u];
      if (!dfs(v, cc)) return 0;
    }
  }
  return 1;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%s", &a[i], &b[i], &s);
    if (s[0] == 'R') {
      g[a[i]].push_back(pair<int, int>(b[i], 1));
      g[b[i]].push_back(pair<int, int>(a[i], 1));
    } else {
      g[b[i]].push_back(pair<int, int>(a[i], 2));
      g[a[i]].push_back(pair<int, int>(b[i], 2));
    }
  }
  int ans = -1;
  vector<int> ans2;
  for (int cc = 1; cc <= 2; cc++) {
    memset(vis, 0, sizeof(vis));
    bool ok = 1;
    int res = 0;
    vector<int> res2;
    for (int i = 1; i <= n; i++) {
      if (vis[i] != 0) continue;
      vis[i] = 1;
      com.clear();
      if (!dfs(i, cc)) {
        ok = 0;
        break;
      }
      int cnt1 = 0, cnt2 = 0;
      for (int j = 0; j < com.size(); j++) {
        int u = com[j];
        if (vis[u] == 1)
          cnt1++;
        else
          cnt2++;
      }
      if (cnt1 < cnt2) {
        res += cnt1;
        for (int j = 0; j < com.size(); j++) {
          int u = com[j];
          if (vis[u] == 1) res2.push_back(u);
        }
      } else {
        res += cnt2;
        for (int j = 0; j < com.size(); j++) {
          int u = com[j];
          if (vis[u] == 2) res2.push_back(u);
        }
      }
    }
    if (!ok) continue;
    if (ans == -1 || ans > res) {
      ans = res;
      ans2 = res2;
    }
  }
  printf("%d\n", ans);
  for (int i = 0; i < ans2.size(); i++) printf("%d ", ans2[i]);
}
