#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

#define MAX_V 100000

int V, E;
vector<int> G[MAX_V];
bool visited[MAX_V];
int prenum[MAX_V];
int parent[MAX_V];
int lowest[MAX_V];
int timer, root;

void add_edge(int from, int to) {
  G[from].push_back(to);
  G[to].push_back(from);
}

void dfs(int u, int prev) {
    prenum[u] = timer;
    lowest[u] = timer;
    timer++;

    visited[u] = true;

    for(int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if(!visited[v]) {
        parent[v] = u;
        dfs(v, u);
        lowest[u] = min(lowest[u], lowest[v]);
      } else if(v != prev) {
        lowest[u] = min(lowest[u], prenum[v]);
      }
    }

}

int main () {
  cin >> V >> E;
  for(int i = 0; i < E; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    add_edge(v1, v2);
  }

  for(int i = 0; i < V; i++) {
    visited[i] = false;
  }
  root = 0;
  timer = 1;
  dfs(root, -1);

  set<int> ans;
  // (1)
  int num = 0;
  for(int i = 0; i < V; i++) {
    if(i == root) continue;
    if(parent[i] == root) num++;
  }
  if(num >= 2) ans.insert(root);

  // (2)
  for(int i = 0; i < V; i++) {
    if(i == root || parent[i] == root) continue;
    else if(prenum[parent[i]] <= lowest[i])
      ans.insert(parent[i]);
    // cout << i << endl;
  }

  set<int>::iterator it = ans.begin();
  while(it != ans.end()) {
    cout << *it << endl;
    it++;
  }

}
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector<s>
#define vvec(s) vector<vector<s>>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout << (x ? "Yes" : "No") << endl;
#define out(s) cout << s << endl;
#define pb(s) push_back(s);
#define sp " "
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(), s.end()
void vout(vi v)
{
    for (int i = 0; i < v.size(); i++)
        cout << v.at(i) << endl;
}
int main()
{
    lli n, m;
    cin >> n >> m;
    vi rec(n, 0);
    lli ans = 0, ans2 = 0;
    vec(bool) c(n, false);
    rep(i, m)
    {
        lli p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "WA")
        {
            rec[p]++;
        }
        else
        {
            if (!c[p])
            {
                ans += rec[p];
                ans2++;
                c[p] = true;
            }
        }
    }
    out(ans2 << sp << ans);
}