#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 400004;
struct dsu {
  int P[N], O[N], U[N];
  void init(int maxn) {
    for (int i = 0; i <= maxn; ++i) {
      P[i] = i;
      O[i] = i % 2;
    }
  }
  int find(int a) { return P[a] == a ? a : (P[a] = find(P[a])); }
  void join(int a, int b) {
    int sa = find(a), sb = find(b);
    if (sa == sb) return;
    P[sb] = sa;
    O[sa] += O[sb];
  }
} A[2];
int b[2], c[2];
int main() {
  int n, m;
  cin >> n >> m;
  A[0].init(2 * n);
  A[1].init(2 * n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    --u;
    --v;
    int r = (c == 'R') ? 0 : 1;
    A[r].join(2 * u, 2 * v);
    A[r].join(2 * u + 1, 2 * v + 1);
    A[1 - r].join(2 * u, 2 * v + 1);
    A[1 - r].join(2 * u + 1, 2 * v);
  }
  for (int i = 0; i < n; ++i) {
    for (int k = 0; k < 2; ++k) {
      if (A[k].find(2 * i) == A[k].find(2 * i + 1)) b[k] = 1;
      if (A[k].find(2 * i) == 2 * i) {
        if (A[k].O[2 * i] <= A[k].O[2 * i + 1])
          A[k].U[2 * i] = 1;
        else
          A[k].U[2 * i + 1] = 1;
        c[k] += min(A[k].O[2 * i], A[k].O[2 * i + 1]);
      }
    }
  }
  if (!b[0] && (c[0] < c[1] || b[1])) {
    cout << c[0] << '\n';
    for (int i = 0; i < n; ++i) {
      int si = A[0].find(2 * i);
      if (!A[0].U[si]) cout << i + 1 << " ";
    }
  } else if (!b[1]) {
    cout << c[1] << '\n';
    for (int i = 0; i < n; ++i) {
      int si = A[1].find(2 * i);
      if (!A[1].U[si]) cout << i + 1 << " ";
    }
  } else
    cout << -1;
}
