#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
struct record {
char id[10];
int hh, mm, ss, time;
char status[4];
}rec[4000001], valid[4000001];
bool cmp(record a, record b) {
int x= strcmp(a.id, b.id);
if(x != 0) return x < 0;
else return a.time < b.time;
}
bool cmp1(record a, record b) {
return a.time < b.time;
}
int main() {
int n, k, hh, mm, ss;
cin >> n >> k;
map<string, int> parkTime;
for(int i = 0; i < n; i++) {
char st[5];
scanf("%s %d:%d:%d %s\n", rec[i].id, &rec[i].hh, &rec[i].mm, &rec[i].ss, &rec[i].status);
rec[i].time = rec[i].hh * 3600 + rec[i].mm * 60 + rec[i].ss;
}
sort(rec, rec + n, cmp);
int num = 0, maxTime = -1;
for(int i = 0; i < n - 1; i++) {
if(!strcmp(rec[i].id, rec[i + 1].id) && !strcmp(rec[i].status, "in") && strcmp(rec[i + 1].status, "in")) {
valid[num++] = rec[i];
valid[num++] = rec[i + 1];
int inTime = rec[i + 1].time - rec[i].time;
if(!parkTime.count(rec[i].id)) parkTime[rec[i].id] = 0;
parkTime[rec[i].id] += inTime;
maxTime = max(maxTime, parkTime[rec[i].id]);
}
}
int now = 0, numCar = 0;
sort(valid, valid + num, cmp1);
for(int i = 0; i < k; i++) {
int hh, mm, ss;
scanf("%d:%d:%d", &hh, &mm, &ss);
int time = hh * 3600 + mm * 60 + ss;
while(now < num && valid[now].time <= time) {
if(!strcmp(valid[now].status, "in")) numCar++;
else numCar--;
now++;
}
printf("%d\n", numCar);
}
map<string, int>::iterator it;
for(it = parkTime.begin(); it != parkTime.end(); it++) {
if(it->second == maxTime) {
printf("%s ", it->first.c_str());
}
}
printf("%02d:%02d:%02d\n", maxTime / 3600, (maxTime % 3600) / 60, maxTime % 60);
return 0;
}
09-16
1171
11-22
337