#include <bits/stdc++.h>
using namespace std;
const int IMPOSSIBLE = -1;
const int NOT_SEEN = -1;
const int SEEN = -1;
struct edge_t {
  int dest;
  bool color;
  int corres;
};
void add_edge(vector<vector<edge_t> > &g, int a, int b, bool color) {
  int index_a = ((int)((g[a]).size())), index_b = ((int)((g[b]).size()));
  g[a].push_back((edge_t){b, color, index_b});
  g[b].push_back((edge_t){a, color, index_a});
}
vector<vector<edge_t> > read_graph() {
  cin.sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<edge_t> > g = vector<vector<edge_t> >(n, vector<edge_t>());
  while (m--) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    add_edge(g, --a, --b, (c == 'B' ? true : false));
  }
  return g;
}
pair<vector<vector<vector<edge_t> > >, vector<vector<int> > > decompose(
    vector<vector<edge_t> > &g) {
  vector<vector<vector<edge_t> > > gs;
  vector<int> convert_index = vector<int>(((int)((g).size())), NOT_SEEN);
  vector<bool> to_see = vector<bool>(((int)((g).size())), false);
  vector<vector<int> > reverse;
  for (int i = 0; i < ((int)((g).size())); i++) {
    if (convert_index[i] == NOT_SEEN) {
      gs.push_back(vector<vector<edge_t> >());
      reverse.push_back(vector<int>());
      queue<int> bfs;
      bfs.push(i);
      to_see[i] = true;
      while (!bfs.empty()) {
        int ind = bfs.front();
        bfs.pop();
        convert_index[ind] = ((int)((gs.back()).size()));
        reverse.back().push_back(ind + 1);
        gs.back().push_back(vector<edge_t>());
        for (edge_t &e : g[ind]) {
          if (!to_see[e.dest]) {
            to_see[e.dest] = true;
            bfs.push(e.dest);
          } else if (convert_index[e.dest] != NOT_SEEN) {
            add_edge(gs.back(), convert_index[ind], convert_index[e.dest],
                     e.color);
          }
        }
      }
    }
  }
  return make_pair(gs, reverse);
}
void negate_graph(vector<vector<edge_t> > &g) {
  for (vector<edge_t> &v : g) {
    for (edge_t &e : v) {
      e.color = !e.color;
    }
  }
}
bool change_vertex(vector<vector<edge_t> > &g, int vertex,
                   vector<int> &to_change) {
  if (to_change[vertex] == SEEN) {
    return false;
  }
  for (edge_t &e : g[vertex]) {
    if (to_change[e.dest] == SEEN) {
      return false;
    }
  }
  for (edge_t &e : g[vertex]) {
    if (e.color) {
      to_change[vertex]++;
      to_change[e.dest]++;
    } else {
      to_change[vertex]--;
      to_change[e.dest]--;
    }
    e.color = !e.color;
    g[e.dest][e.corres].color = !g[e.dest][e.corres].color;
  }
  return true;
}
void print_to_change(vector<int> &to_change) {
  for (int e : to_change) {
    cout << e << ", ";
  }
  cout << endl;
}
pair<int, vector<int> > solve(vector<vector<edge_t> > g, int starting_node) {
  vector<int> to_change = vector<int>(((int)((g).size())), 0);
  vector<int> to_look = vector<int>(((int)((g).size())), false);
  vector<int> solution;
  for (int i = 0; i < ((int)((g).size())); i++) {
    for (edge_t &e : g[i]) {
      if (!e.color) to_change[i]++;
    }
  }
  queue<int> bfs;
  bfs.push(starting_node);
  to_look[starting_node] = true;
  while (!bfs.empty()) {
    int node = bfs.front();
    bfs.pop();
    for (edge_t &e : g[node]) {
      if (!e.color) {
        if (change_vertex(g, e.dest, to_change)) {
          solution.push_back(e.dest);
        } else {
          return make_pair(IMPOSSIBLE, vector<int>());
        }
      }
      if (!to_look[e.dest]) {
        bfs.push(e.dest);
        to_look[e.dest] = true;
      }
    }
    to_change[node] = SEEN;
  }
  return make_pair(((int)((solution).size())), solution);
}
pair<int, int> search_start(vector<vector<edge_t> > &g) {
  for (int i = 0; i < ((int)((g).size())); i++) {
    for (edge_t &e : g[i]) {
      if (!e.color) return make_pair(i, e.dest);
    }
  }
  return make_pair(IMPOSSIBLE, IMPOSSIBLE);
}
void add(int sol1, vector<int> &nodes1, int sol2, vector<int> &nodes2, int &sum,
         vector<int> &vertices, vector<int> &reverse) {
  if (sol1 != IMPOSSIBLE && sol2 != IMPOSSIBLE) {
    if (sol1 < sol2) {
      sum += sol1;
      for (int nd : nodes1) {
        vertices.push_back(reverse[nd]);
      }
    } else {
      sum += sol2;
      for (int nd : nodes2) {
        vertices.push_back(reverse[nd]);
      }
    }
  } else if (sol1 != IMPOSSIBLE) {
    sum += sol1;
    for (int nd : nodes1) {
      vertices.push_back(reverse[nd]);
    }
  } else {
    sum += sol2;
    for (int nd : nodes2) {
      vertices.push_back(reverse[nd]);
    }
  }
}
pair<int, vector<int> > solve_all(vector<vector<edge_t> > &all) {
  int sum = 0;
  vector<int> vertices;
  vector<vector<vector<edge_t> > > gs;
  vector<vector<int> > reverse;
  tie(gs, reverse) = decompose(all);
  for (int i = 0; i < ((int)((gs).size())); i++) {
    int vertex1, vertex2;
    tie(vertex1, vertex2) = search_start(gs[i]);
    if (vertex1 != IMPOSSIBLE) {
      int sol1, sol2;
      vector<int> nodes1, nodes2;
      tie(sol1, nodes1) = solve(gs[i], vertex1);
      tie(sol2, nodes2) = solve(gs[i], vertex2);
      if (sol1 == IMPOSSIBLE && sol2 == IMPOSSIBLE) {
        return make_pair(IMPOSSIBLE, vector<int>());
      } else {
        add(sol1, nodes1, sol2, nodes2, sum, vertices, reverse[i]);
      }
    }
  }
  return make_pair(sum, vertices);
}
void print_graph(vector<vector<edge_t> > &g) {
  cout << "----------------------------------------------------------------\n";
  for (int i = 0; i < ((int)((g).size())); i++) {
    for (edge_t &e : g[i]) {
      cout << "(" << i << ", " << e.dest << ", " << (e.color ? "true" : "false")
           << ")\n";
    }
  }
}
void print_solution(pair<int, vector<int> > &p) {
  cout << p.first << endl;
  for (int e : p.second) {
    cout << e << " ";
  }
}
void compare_solution(pair<int, vector<int> > &p1,
                      pair<int, vector<int> > &p2) {
  if (p1.first == IMPOSSIBLE && p2.first == IMPOSSIBLE) {
    cout << "-1";
  } else if (p1.first != IMPOSSIBLE && p2.first != IMPOSSIBLE) {
    if (p1.first < p2.first)
      print_solution(p1);
    else
      print_solution(p2);
  } else if (p1.first != IMPOSSIBLE) {
    print_solution(p1);
  } else {
    print_solution(p2);
  }
}
int main() {
  vector<vector<edge_t> > g = read_graph();
  pair<int, vector<int> > p1, p2;
  p1 = solve_all(g);
  negate_graph(g);
  p2 = solve_all(g);
  compare_solution(p1, p2);
}
