You are given an undirected graph that consists of n vertices and m edges. Initially, each edge is colored either red or blue. Each turn a player picks a single vertex and switches the color of all edges incident to it. That is, all red edges with an endpoint in this vertex change the color to blue, while all blue edges with an endpoint in this vertex change the color to red.

Find the minimum possible number of moves required to make the colors of all edges equal.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100 000) — the number of vertices and edges, respectively.

The following m lines provide the description of the edges, as the i-th of them contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the indices of the vertices connected by the i-th edge, and a character ci (<image>) providing the initial color of this edge. If ci equals 'R', then this edge is initially colored red. Otherwise, ci is equal to 'B' and this edge is initially colored blue. It's guaranteed that there are no self-loops and multiple edges.

Output

If there is no way to make the colors of all edges equal output  - 1 in the only line of the output. Otherwise first output k — the minimum number of moves required to achieve the goal, then output k integers a1, a2, ..., ak, where ai is equal to the index of the vertex that should be used at the i-th move.

If there are multiple optimal sequences of moves, output any of them.

Examples

Input

3 3
1 2 B
3 1 R
3 2 B


Output

1
2 


Input

6 5
1 3 R
2 3 R
3 4 B
4 5 R
4 6 R


Output

2
3 4 


Input

4 5
1 2 R
1 3 R
2 3 B
3 4 B
1 4 B


Output

-1
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int i, j, k, l, z, flag, fl, Final, ans[N], b[N], n, m, x, y, nP;
char c;
vector<pair<int, int> > e[N];
void dfs(int x) {
  int i, y, l = e[x].size(), state;
  if (flag == 1) return;
  for (i = 0; i < l; i++) {
    y = e[x][i].first;
    state = (e[x][i].second) ^ ans[x];
    if (flag) return;
    if (b[y] == 1) {
      state ^= ans[y];
      if (state != Final) {
        flag = 1;
        return;
      }
    } else {
      if (state != Final)
        ans[y] = 1, nP++;
      else
        ans[y] = 0;
      b[y] = 1;
      dfs(y);
    }
  }
}
void dfs_clear(int x) {
  int i, y, l = e[x].size();
  for (i = 0; i < l; i++) {
    y = e[x][i].first;
    if (b[y] == 1) {
      b[y] = 0;
      dfs_clear(y);
    }
  }
}
int df(int x, int z) {
  flag = 0;
  dfs_clear(x);
  ans[x] = z;
  b[x] = 1;
  nP = 0;
  nP = z;
  dfs(x);
  if (flag == 1) return (N + 1);
  return nP;
}
int qwe(int Fin) {
  Final = Fin;
  int q, P, Q = 0, i;
  memset(ans, 0, sizeof(ans));
  memset(b, 0, sizeof(b));
  for (i = 1; i <= n; i++)
    if (b[i] == 0) {
      if (df(i, 0) < df(i, 1))
        q = df(i, 0);
      else
        q = df(i, 1);
      if (q == N + 1) break;
      Q += q;
    }
  if (i <= n) return N + 1;
  return Q;
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d %c", &x, &y, &c);
    z = (c == 'B') ? (0) : (1);
    e[x].push_back(make_pair(y, z));
    e[y].push_back(make_pair(x, z));
  }
  if (qwe(1) > qwe(0))
    ans[0] = qwe(0);
  else
    ans[0] = qwe(1);
  if (ans[0] == N + 1)
    puts("-1");
  else {
    ans[0] = 0;
    for (i = 1; i <= n; i++)
      if (ans[i]) ans[0]++;
    printf("%d\n", ans[0]);
    for (i = 1; i <= n; i++)
      if (ans[i]) printf("%d ", i);
  }
  return 0;
}
