#include <iostream>
#include <cstring>
#include <cmath>
#include <stack>
#include <map>
#include <algorithm>
#include <string>
#define maxn 210
using namespace std;
int GetT(string s1,string s2)
{
int h1,h2,m1,m2;
h1 = (s1[1]-'0')+(s1[0]-'0')*10;
m1 = (s1[4]-'0')+(s1[3]-'0')*10;
h2 = (s2[1]-'0')+(s2[0]-'0')*10;
m2 = (s2[4]-'0')+(s2[3]-'0')*10;
int ans = (h2*60+m2)-(h1*60+m1);
return ans;
}
bool flag[maxn]={0};
string t[maxn];
int main() {
int N;
char K;
string T;
int cnt=0;
float ave=0;
while(cin>>N>>K>>T)
{
if(N==-1)break;
else if(N==0)
{
if(cnt)ave =ave*1.0/ cnt;
else {
ave=0;
cnt=0;
}
printf("%d %.f\n",cnt,ave);
cnt=0;
ave = 0;
memset(flag,false,sizeof(flag));
}
else {
if(K=='E'&&flag[N]==1)
{
string now = T;
ave += GetT(t[N],T);
// cout<<N<<" : "<<GetT(t[N],T)<<endl;
cnt++;
// flag[N]=0;之前置零后就错了-->题目bug不用置零
}
else if(K =='S'){
flag[N] = 1;
t[N] = T;
}
}
}
}
// 64 位输出请用 printf("%lld")