#include <bits/stdc++.h>
using namespace std;
int nex[1000000], d[1000000], sum, cnt2, cnt1, booo[1000000], root, a[1000000],
    len, n, m, wen[1000000], hea[1000000], col[1000000], anss[1000000],
    ans2[1000000], ans1[1000000], t, boo;
void add(int x, int y, int z) {
  ++len;
  nex[len] = hea[x];
  wen[len] = y;
  col[len] = z;
  hea[x] = len;
}
void dfs(int x, int bo, int c) {
  d[++sum] = x;
  booo[x] = 1;
  a[x] = bo;
  if (bo) {
    ++t;
    anss[t] = x;
  }
  for (int i = hea[x]; i; i = nex[i])
    if (!booo[wen[i]]) {
      dfs(wen[i], abs(abs(c - col[i]) - bo), c);
      if (!boo) return;
    } else {
      if (abs(a[x] - a[wen[i]]) != abs(col[i] - c)) {
        boo = 0;
        return;
      }
    }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    char ch = getchar();
    while (ch != 'R' && ch != 'B') ch = getchar();
    add(x, y, ch == 'R');
    add(y, x, ch == 'R');
  }
  root = 1;
  do {
    sum = 0;
    boo = 1;
    t = 0;
    dfs(root, 1, 1);
    if (boo) {
      if (sum - t >= t) {
        for (int i = 1; i <= t; i++) ans1[cnt1 + i] = anss[i];
        cnt1 += t;
      } else {
        for (int i = 1, j = 1, k = 1; i <= sum; i++, k++) {
          while (d[i] == anss[j] && i <= sum && j <= t) ++i, ++j;
          ans1[cnt1 + k] = d[i];
        }
        cnt1 += sum - t;
      }
    } else {
      cnt1 = -1;
      break;
    }
    for (int i = root + 1; i <= n + 1; i++)
      if (booo[i] == 0) {
        root = i;
        break;
      }
  } while (root <= n);
  for (int i = 1; i <= n; i++) a[i] = booo[i] = 0;
  root = 1;
  do {
    sum = 0;
    boo = 1;
    t = 0;
    dfs(root, 1, 0);
    if (boo) {
      if (sum - t >= t) {
        for (int i = 1; i <= t; i++) ans2[cnt2 + i] = anss[i];
        cnt2 += t;
      } else {
        for (int i = 1, j = 1, k = 1; i <= sum; i++, k++) {
          while (d[i] == anss[j] && i <= sum && j <= t) ++i, ++j;
          ans2[cnt2 + k] = d[i];
        }
        cnt2 += sum - t;
      }
    } else {
      cnt2 = -1;
      break;
    }
    for (int i = root + 1; i <= n + 1; i++)
      if (booo[i] == 0) {
        root = i;
        break;
      }
  } while (root <= n);
  if (cnt1 == cnt2 && cnt1 == -1) {
    puts("-1");
    return 0;
  }
  if ((cnt1 < cnt2 || cnt2 == -1) && cnt1 != -1) {
    printf("%d\n", cnt1);
    for (int i = 1; i <= cnt1; i++) printf("%d ", ans1[i]);
  } else {
    printf("%d\n", cnt2);
    for (int i = 1; i <= cnt2; i++) printf("%d ", ans2[i]);
  }
}
