#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
vector<pair<int, int>> g[maxn];
int col[maxn];
vector<int> zero, one;
bool bad = false;
void dfs(int u, int c) {
  for (const auto &[v, e] : g[u]) {
    if (col[v] == -1) {
      if (e == c) {
        col[v] = col[u];
      } else {
        col[v] = 1 ^ col[u];
      }
      dfs(v, c);
    } else {
      if (e == c && col[v] != col[u]) bad = true;
      if (e != c && col[v] == col[u]) bad = true;
    }
  }
  if (col[u])
    one.push_back(u + 1);
  else
    zero.push_back(u + 1);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int u, v;
  char c;
  memset(col, -1, sizeof(col));
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    cin >> c;
    --u;
    --v;
    g[u].push_back(make_pair(v, c == 'R' ? 0 : 1));
    g[v].push_back(make_pair(u, c == 'R' ? 0 : 1));
  }
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    if (col[i] == -1) {
      zero.clear();
      one.clear();
      col[i] = 0;
      dfs(i, 0);
      if (bad) break;
      if (one.size() < zero.size()) {
        ans.insert(ans.end(), one.begin(), one.end());
      } else {
        ans.insert(ans.end(), zero.begin(), zero.end());
      }
    }
  }
  if (!bad && ans.size() == 0) {
    cout << "0\n";
    return 0;
  }
  memset(col, -1, sizeof(col));
  vector<int> a;
  if (!bad) a = ans;
  bad = false;
  ans.clear();
  for (int i = 0; i < n; ++i) {
    if (col[i] == -1) {
      zero.clear();
      one.clear();
      col[i] = 0;
      dfs(i, 1);
      if (bad) break;
      if (one.size() < zero.size()) {
        ans.insert(ans.end(), one.begin(), one.end());
      } else {
        ans.insert(ans.end(), zero.begin(), zero.end());
      }
    }
  }
  if (a.empty() && bad) {
    cout << "-1\n";
    return 0;
  }
  if (!a.empty() && !bad) {
    std::cout << min(a.size(), ans.size()) << "\n";
    if (a.size() < ans.size()) {
      for (int x : a) {
        cout << x << " ";
      }
    } else {
      for (int x : ans) {
        cout << x << " ";
      }
    }
    return 0;
  }
  if (!a.empty()) {
    cout << a.size() << endl;
    for (int x : a) cout << x << " ";
    return 0;
  }
  cout << ans.size() << endl;
  for (int x : ans) cout << x << " ";
}
