#include <iostream>
#include <string>
#include <map>
using namespace std;
int add(string a, string b) {
    int h = (a[0] - b[0]) * 10 + a[1] - b[1];
    int m = (a[3] - b[3]) * 10 + a[4] - b[4];
    // cout << "h : " << h << "  m : " << m << endl;
    return h * 60 + m;
}
int main() {
    int a, cnt = 0, ans = 0;
    char c;
    string time, last_time = "24:00:00", INF = last_time;
    map<int, string> m;
    while (cin >> a >> c >> time && a != -1) { // 注意 while 处理多个 case
        if (time <= last_time) {
            if (last_time != INF) {
                if (cnt) {
                    ans = (double) ans / cnt + 0.5;
                }
                cout << cnt << ' ' << ans << endl;
            }
            m.clear();
            cnt = 0, ans = 0;
        }

        if (c == 'S') m[a] = time;
        else if (c == 'E') {
            if (m.count(a) && m[a] != INF) {
                cnt ++;
                ans += add(time, m[a]);
                // m[a] = INF;
            }
        }
        last_time = time;
    }
    if (cnt) {
        ans = (double) ans / cnt + 0.5;
    }
    cout << cnt << ' ' << ans << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")