#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
  ll n,m;
  cin >> n >> m;
  
  ll p[m];
  string s[m];
  rep(i,m) cin >> p[i] >> s[i];
  
  ll acnum[n+1];
  for(ll i = 0; i < m; i++){
    if(s[i] == "AC"){
      acnum[p[i]] = 1;
    }
  }
  
  ll ac = 0, wa = 0;
  ll ok[n+1];
  for(ll i = 1; i <= n; i++) ok[i] = 0;
  for(ll i = 0; i < m; i++){
    if(s[i] == "WA" && ok[p[i]] == 0 && acnum[p[i]] == 1){
      wa++;
    }
    if(s[i] == "AC" && ok[p[i]] == 0){
      ok[p[i]] = 1;
      ac++;
    }
  }
  
  cout << ac << " " << wa << endl;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n, -1), s(n), c(n);
    rep1(i, m) cin >> s[i] >> c[i];
    rep1(i, m){
        if (a[s[i]-1]!=-1 && a[s[i]-1]!=c[i]){
            cout << -1 << endl;
            return 0;
        }
        a[s[i]-1] = c[i];
    }
    if (a[0]==0 && n>1){
        cout << -1 << endl;
        return 0;
    }
    rep1(i, n){
        if (i==0 && n>1){
            if (a[i]==-1) cout << 1;
            else cout << a[i];
        }else{
            if (a[i]==-1) cout << 0;
            else cout << a[i];
        }
    }
}