#include <bits/stdc++.h>
using namespace std;
int cond = (long long)1;
vector<int> ed_dest[111111];
vector<int> ed_col[111111];
int n, m;
int par[111111];
int dist[111111];
vector<int> odd[111111];
vector<int> even[111111];
int parent(int cur, int &res) {
  if (par[cur] == cur) {
    res = 0;
    return cur;
  }
  int p2 = parent(par[cur], res);
  res ^= dist[cur];
  dist[cur] = res;
  par[cur] = p2;
  return par[cur];
}
int calc(char dest, vector<int> &wyn) {
  for (auto i = (1); i <= (n); ++i) {
    par[i] = i;
    dist[i] = 0;
    odd[i].clear();
    even[i].clear();
  }
  for (auto i = (1); i <= (n); ++i) {
    for (auto j = (0); j < ((int)ed_dest[i].size()); ++j) {
      int b = ed_dest[i][j];
      int zn = ed_col[i][j];
      int val = (zn == dest) ? 0 : 1;
      int r1, r2;
      int p1 = parent(i, r1);
      int p2 = parent(b, r2);
      {
        if (cond > 0) {
          cond--;
          for (auto xxx = (0); xxx < (1); ++xxx)
            cerr << 58 << " "
                 << "i << \" \" << b << \" \" << p1 << \" \" << p2 << \" \" << "
                    "r1 << \" \" << r2 << \" \" << val"
                 << " " << i << " " << b << " " << p1 << " " << p2 << " " << r1
                 << " " << r2 << " " << val << endl;
          cerr.flush();
        }
      };
      if (p1 == p2) {
        if ((r1 ^ r2) != val) {
          {
            if (cond > 0) {
              cond--;
              for (auto xxx = (0); xxx < (1); ++xxx)
                cerr << 63 << " "
                     << "\"not\" << \"\" << i << \" \" << b << \" \" << p1 << "
                        "\" \" << p2 << \" \" << r1 << \" \" << r2 << \" \" << "
                        "val"
                     << " "
                     << "not"
                     << "" << i << " " << b << " " << p1 << " " << p2 << " "
                     << r1 << " " << r2 << " " << val << endl;
              cerr.flush();
            }
          };
          return (int)1e9;
        }
      } else {
        par[p1] = p2;
        dist[p1] = val ^ r1 ^ r2;
        parent(i, r1);
        parent(b, r2);
        assert((r1 ^ r2) == val);
      }
    }
  }
  for (auto i = (1); i <= (n); ++i) {
    int r1;
    int p1 = parent(i, r1);
    if (r1 == 1)
      odd[p1].push_back(i);
    else
      even[p1].push_back(i);
  }
  for (auto i = (1); i <= (n); ++i) {
    if (odd[i].size() < even[i].size()) {
      for (auto it = (odd[i]).begin(); it != (odd[i]).end(); ++it)
        wyn.push_back(*it);
    } else {
      for (auto it = (even[i]).begin(); it != (even[i]).end(); ++it)
        wyn.push_back(*it);
    }
  }
  int res = wyn.size();
  return res;
}
void solve() {
  cin >> n >> m;
  {
    if (cond > 0) {
      cond--;
      for (auto xxx = (0); xxx < (1); ++xxx)
        cerr << 95 << " "
             << "n << \" \" << m"
             << " " << n << " " << m << endl;
      cerr.flush();
    }
  };
  for (auto j = (0); j < (m); ++j) {
    int a, b;
    cin >> a >> b;
    char col;
    cin >> col;
    {
      if (cond > 0) {
        cond--;
        for (auto xxx = (0); xxx < (1); ++xxx)
          cerr << 101 << " "
               << "j << \" \" << a << \" \" << b << \" \" << col"
               << " " << j << " " << a << " " << b << " " << col << endl;
        cerr.flush();
      }
    };
    ed_dest[a].push_back(b);
    ed_col[a].push_back(col);
    ed_dest[b].push_back(a);
    ed_col[b].push_back(col);
  }
  int res = (int)1e9;
  vector<int> wyn1, wyn2;
  vector<int> wyn;
  int res1 = calc('B', wyn1);
  int res2 = calc('R', wyn2);
  if (res1 < res2) {
    res = res1;
    wyn = wyn1;
  } else {
    res = res2;
    wyn = wyn2;
  }
  if (res == (int)1e9)
    cout << -1 << endl;
  else {
    sort((wyn).begin(), (wyn).end());
    {
      if (cond > 0) {
        cond--;
        for (auto xxx = (0); xxx < (1); ++xxx)
          cerr << 123 << " "
               << "res << \" \" << wyn.size()"
               << " " << res << " " << wyn.size() << endl;
        cerr.flush();
      }
    }
    cout << res << endl;
    for (auto i = (0); i < (wyn.size()); ++i) {
      if (i > 0) cout << " ";
      cout << wyn[i];
    }
    cout << endl;
  }
}
const int multi = 0;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cond = argc >= 2 && argv[1][0] == 'q' ? 1 << 30 : 0;
  int t;
  if (multi)
    cin >> t;
  else
    t = 1;
  for (auto i = (1); i <= (t); ++i) {
    if (cond) cerr << 141 << " " << i << endl;
    if (multi) cout << "Case #" << i << ":";
    solve();
  }
  return 0;
}
