#include <bits/stdc++.h>
using std::copy;
using std::inserter;
using std::swap;
using std::vector;
const int MAX_N = 100000 + 10;
struct Edge {
  int v, color;
};
int n;
vector<Edge> G[MAX_N];
int num_cc;
int cc_id[MAX_N];
vector<int> cc[MAX_N];
int color[MAX_N];
void ReadGraph(void) {
  int m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    char s[2];
    scanf("%d%d%s", &u, &v, s);
    int color = s[0] == 'R';
    G[u - 1].push_back((Edge){v - 1, color});
    G[v - 1].push_back((Edge){u - 1, color});
  }
}
void DFS(int u) {
  cc_id[u] = num_cc;
  cc[num_cc].push_back(u);
  for (int i = 0; i < (int)G[u].size(); ++i) {
    Edge &e = G[u][i];
    if (cc_id[e.v] == -1) {
      DFS(e.v);
    }
  }
}
void FindCC(void) {
  num_cc = 0;
  memset(cc_id, -1, sizeof cc_id);
  for (int i = 0; i < n; ++i) {
    if (cc_id[i] == -1) {
      cc[num_cc].clear();
      DFS(i);
      ++num_cc;
    }
  }
}
void ChooseBetter(bool &good1, vector<int> &list1, bool &good2,
                  vector<int> &list2) {
  if (good2 && (!good1 || list1.size() > list2.size())) {
    swap(good1, good2);
    swap(list1, list2);
  }
}
void WriteList(vector<int> &list) {
  printf("%u\n", list.size());
  for (int i = 0; i < (int)list.size(); ++i) {
    printf("%d ", list[i] + 1);
  }
  printf("\n");
}
bool DFS2(int u, int goal, vector<int> &list) {
  for (int i = 0; i < (int)G[u].size(); ++i) {
    Edge &e = G[u][i];
    if (e.color == goal) {
      if (color[e.v] == -1) {
        color[e.v] = color[u];
        if (color[e.v]) {
          list.push_back(e.v);
        }
        if (!DFS2(e.v, goal, list)) {
          return false;
        }
      } else if (color[e.v] != color[u]) {
        return false;
      }
    } else {
      if (color[e.v] == -1) {
        color[e.v] = color[u] ^ 1;
        if (color[e.v]) {
          list.push_back(e.v);
        }
        if (!DFS2(e.v, goal, list)) {
          return false;
        }
      } else if (color[e.v] == color[u]) {
        return false;
      }
    }
  }
  return true;
}
bool SolveCC(int id, int goal, vector<int> &list) {
  int root = cc[id].front();
  bool good1, good2;
  vector<int> now1, now2;
  for (int i = 0; i < (int)cc[id].size(); ++i) {
    color[cc[id][i]] = -1;
  }
  color[root] = 0;
  good1 = DFS2(root, goal, now1);
  for (int i = 0; i < (int)cc[id].size(); ++i) {
    color[cc[id][i]] = -1;
  }
  color[root] = 1;
  now2.push_back(root);
  good2 = DFS2(root, goal, now2);
  ChooseBetter(good1, now1, good2, now2);
  if (good1) {
    copy(now1.begin(), now1.end(), inserter(list, list.end()));
    return true;
  } else {
    return false;
  }
}
void Solve(int goal, bool &good, vector<int> &list) {
  list.clear();
  for (int i = 0; i < num_cc; ++i) {
    if (!SolveCC(i, goal, list)) {
      good = false;
      return;
    }
  }
  good = true;
}
int main(void) {
  ReadGraph();
  FindCC();
  bool good1, good2;
  vector<int> list1, list2;
  Solve(0, good1, list1);
  Solve(1, good2, list2);
  ChooseBetter(good1, list1, good2, list2);
  if (good1) {
    WriteList(list1);
  } else {
    puts("-1");
  }
}
