#include <bits/stdc++.h>
using namespace std;
vector<int> adjlist[200005];
int color[200005];
vector<pair<int, int> > adj[200005];
vector<int> col1, col2;
vector<int> minimumcolored;
vector<int> test;
int n, m;
bool bipartite(int s = 0) {
  col1.clear();
  col2.clear();
  queue<int> q;
  q.push(s);
  color[s] = 0;
  col2.push_back(s);
  bool isBipartite = true;
  while (!q.empty() & isBipartite) {
    int u = q.front();
    q.pop();
    for (int j = 0; j < (int)adjlist[u].size(); j++) {
      int v = adjlist[u][j];
      if (color[v] == -1) {
        color[v] = 1 - color[u];
        if (v < n) {
          if (color[v] == 0)
            col2.push_back(v);
          else
            col1.push_back(v);
        }
        q.push(v);
      } else if (color[v] == color[u]) {
        isBipartite = false;
        break;
      }
    }
  }
  return isBipartite;
}
void pr(vector<int> a) {
  return;
  cout << a.size() << '\n';
  for (int i = 0; i < (int)(a.size()); i++) cout << a[i] << " ";
  cout << '\n';
}
int extra;
vector<int> solvefor(int COLOR) {
  minimumcolored.clear();
  extra = n;
  for (int i = 0; i < (int)(200005); i++) {
    adjlist[i].clear();
  }
  for (int i = 0; i < (int)(n); i++) {
    int u = i;
    for (int j = 0; j < (int)(adj[i].size()); j++) {
      int v, col;
      tie(v, col) = adj[i][j];
      if (col == COLOR) {
        adjlist[u].push_back(extra);
        adjlist[extra].push_back(u);
        adjlist[extra].push_back(v);
        adjlist[v].push_back(extra);
        extra++;
      } else {
        adjlist[u].push_back(v);
        adjlist[v].push_back(u);
      }
    }
  }
  memset(color, -1, sizeof(color));
  ;
  for (int k = 0; k < (int)(n); k++) {
    if (color[k] == -1) {
      bool ans = bipartite(k);
      if (!ans) {
        return test;
      }
      if (col1.size() < col2.size()) {
        col2 = col1;
      }
      for (int i = 0; i < (int)(col2.size()); i++) {
        minimumcolored.push_back(col2[i]);
      }
    }
  }
  return minimumcolored;
}
vector<int> a, b;
void solve() {
  cin >> n >> m;
  for (int i = 0; i < (int)(n + 3); i++) {
    test.push_back(-1);
  }
  for (int i = 0; i < (int)(m); i++) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    int cc;
    if (c == 'R')
      cc = 0;
    else
      cc = 1;
    a--;
    b--;
    adj[a].push_back(make_pair(b, cc));
  }
  a = solvefor(0);
  b = solvefor(1);
  pr(a);
  pr(b);
  if (a.size() < b.size()) {
    b = a;
  }
  if (b.size() > n) {
    cout << -1;
  } else {
    cout << b.size() << '\n';
    for (int i = 0; i < (int)(b.size()); i++) {
      cout << b[i] + 1 << " ";
    }
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  int TC = 1;
  for (int ZZ = 1; ZZ <= TC; ZZ++) {
    clock_t start = clock();
    solve();
    clock_t end = clock();
    cerr << "Time: " << (double)(end - start) / CLOCKS_PER_SEC << " seconds"
         << '\n';
  }
  return 0;
}
