#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int lim = 2e5 + 10;
struct self {
  int x, y, w, nxt;
} source[lim];
self s[2][lim << 1];
int fst[2][lim];
int flag[2][lim];
int cnt[2][lim];
int cntnum[2];
int cntans[2][lim];
int cnthas[2][lim];
int m, n[2];
int tn;
int x, y, w;
char ch;
void add(int k, int x, int y) {
  n[k]++;
  s[k][n[k]].y = y;
  s[k][n[k]].nxt = fst[k][x];
  fst[k][x] = n[k];
}
int ok[2];
int pt(int u) { return u > m ? u - m : u + m; }
void dfs(int k, int u, int c) {
  flag[k][u] = 1;
  flag[k][pt(u)] = 0;
  cnt[k][u] = c;
  cnt[k][pt(u)] = c;
  cnthas[k][c]++;
  if (u <= m) cntans[k][c]++;
  for (int e = fst[k][u]; e != -1; e = s[k][e].nxt) {
    int v = s[k][e].y;
    if (flag[k][v] == 0) {
      ok[k] = 0;
      return;
    }
    if (flag[k][v] == -1) dfs(k, v, c);
  }
}
void print() {
  int ans[2];
  ans[0] = ans[1] = inf;
  for (int k = 0; k <= 1; k++)
    if (ok[k]) {
      ans[k] = 0;
      for (int i = 1; i <= cntnum[k]; i++)
        ans[k] = ans[k] + min(cntans[k][i], cnthas[k][i] - cntans[k][i]);
    }
  int k;
  if (ans[0] < ans[1])
    k = 0;
  else
    k = 1;
  if (ans[k] == inf) {
    printf("-1\n");
    return;
  }
  printf("%d\n", ans[k]);
  for (int i = 1; i <= m; i++) {
    int belong = cnt[k][i];
    if (cntans[k][belong] < cnthas[k][belong] - cntans[k][belong])
      if (flag[k][i] == 1)
        printf("%d ", i);
      else
        ;
    else if (flag[k][i] == 0)
      printf("%d ", i);
    else
      ;
  }
}
int main() {
  ok[0] = ok[1] = 1;
  scanf("%d%d", &m, &tn);
  for (int i = 1; i <= tn; i++) {
    scanf("%d%d %c", &x, &y, &ch);
    source[i].x = x;
    source[i].y = y;
    source[i].w = (ch == 'R' ? 0 : 1);
  }
  memset(flag, -1, sizeof(flag));
  memset(fst, -1, sizeof(fst));
  for (int i = 1; i <= tn; i++) {
    x = source[i].x;
    y = source[i].y;
    if (source[i].w == 0) {
      add(0, x, y);
      add(0, y, x);
      add(0, x + m, y + m);
      add(0, y + m, x + m);
      add(1, x, y + m);
      add(1, y, x + m);
      add(1, y + m, x);
      add(1, x + m, y);
    } else {
      add(0, x, y + m);
      add(0, y, x + m);
      add(0, x + m, y);
      add(0, y + m, x);
      add(1, x, y);
      add(1, y, x);
      add(1, x + m, y + m);
      add(1, y + m, x + m);
    }
  }
  for (int i = 1; i <= m; i++)
    if (flag[0][i] == -1 && ok[0]) {
      cntnum[0]++;
      dfs(0, i, cntnum[0]);
    }
  for (int i = 1; i <= m; i++)
    if (flag[1][i] == -1 && ok[1]) {
      cntnum[1]++;
      dfs(1, i, cntnum[1]);
    }
  print();
  return 0;
}
