#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, tmp, acu;
bool bisa[3];
bitset<100001> vis, ar;
vector<pair<int, int> > adj[100001];
vector<int> warna[3], part[2];
pair<pair<int, int>, int> edlist[100001];
pair<int, int> tme;
char c;
void calc(int wrn) {
  queue<int> q;
  for (int t = 1; t <= n; ++t)
    if (!vis[t]) {
      part[0].clear(), part[1].clear();
      vis[t] = true, q.push(t);
      while (!q.empty()) {
        a = q.front(), q.pop();
        part[ar[a]].push_back(a);
        for (pair<int, int> i : adj[a])
          if (!vis[i.first]) {
            if (i.second == wrn)
              ar[i.first] = ar[a];
            else
              ar[i.first] = !ar[a];
            vis[i.first] = true;
            q.push(i.first);
          }
      }
      tmp = (part[0].size() > part[1].size());
      warna[wrn].insert(warna[wrn].end(), part[tmp].begin(), part[tmp].end());
    }
  bisa[wrn] = true, acu = 0;
  for (int i = 1; i <= n; ++i)
    if (ar[i]) ++acu;
  for (int i = 1; i <= m; ++i) {
    tme = edlist[i].first;
    if (edlist[i].second == wrn) {
      if (ar[tme.first] != ar[tme.second]) {
        bisa[wrn] = false;
        break;
      }
    } else {
      if (ar[tme.first] == ar[tme.second]) {
        bisa[wrn] = false;
        break;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> a >> b >> c;
    tmp = (c == 'R') + 1;
    adj[a].push_back(make_pair(b, tmp));
    adj[b].push_back(make_pair(a, tmp));
    edlist[i] = make_pair(make_pair(a, b), tmp);
  }
  calc(2);
  vis.reset(), ar.reset();
  calc(1);
  if (bisa[1] && bisa[2]) {
    if (warna[1].size() < warna[2].size())
      tmp = 1;
    else
      tmp = 2;
    cout << warna[tmp].size() << '\n';
    for (int i : warna[tmp]) cout << i << ' ';
  } else if (bisa[1]) {
    cout << warna[1].size() << '\n';
    for (int i : warna[1]) cout << i << ' ';
  } else if (bisa[2]) {
    cout << warna[2].size() << '\n';
    for (int i : warna[2]) cout << i << ' ';
  } else {
    cout << "-1";
  }
  cout << '\n';
}
