#include<iostream>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <sstream>
#define M 500
using namespace std;
char s[M];
struct Node {
// int year, month, date;
int hour, minutes, seconds;
Node() {
hour = minutes = seconds = 0;
}
bool operator<(Node a) {
return hour * 60 * 60 + minutes * 60 + seconds < a.hour * 60 * 60 + a.minutes * 60 + a.seconds;
}
Node turn(Node a) {
Node t;
t.minutes = minutes - a.minutes;
t.seconds = seconds - a.seconds;
// t.date = date - a.date;
// t.month = date - a.date;
// t.year = year - a.year;
t.hour = hour - a.hour;
if (t.seconds < 0)t.seconds += 60, t.minutes--;
if (t.minutes < 0)t.minutes += 60, t.hour--;
t.minutes += t.seconds / 60;
t.seconds %= 60;
t.hour += t.minutes / 60;
t.minutes %= 60;
return t;
// t.hour += t.date * 24 + t.month * 30 + t.year * 365;
}
void add(Node a) {
minutes = minutes + a.minutes;
seconds = seconds + a.seconds;
hour = hour + a.hour;
if (seconds < 0)seconds += 60, minutes--;
if (minutes < 0)minutes += 60, hour--;
minutes += seconds / 60;
seconds %= 60;
hour += minutes / 60;
minutes %= 60;
}
} f, t, z, now;
struct Team {
char name[M];
Node time[M];
int num;
Node ttime;
int solve[M];
Team() {
memset(solve, 0, sizeof (solve));
num = 0;
}
} team[M];
int cmp(Team a, Team b) {
if (a.num != b.num)
return a.num > b.num;
return a.ttime < b.ttime;
}
int pro[M];
int main(int argc, char** argv) {
ifstream out;
int id;
char name[25];
int problem;
char state[25];
char L[3][25];
char tmp[50];
int y, mon, d;
int h, min, se;
cin >> s;
out.open(s);
int num;
bool ok = false;
int n = 0;
out >> tmp >> s;
sscanf(s, "%d:%d:%d", &f.hour, &f.minutes, &f.seconds);
out >> tmp >> s;
sscanf(s, "%d:%d:%d", &t.hour, &t.minutes, &t.seconds);
out.get();
out.getline(s, 1000, '\n');
stringstream sin(s);
while (sin >> num) {
pro[n] = num;
n++;
}
int nn = 0;
int pid;
while (!out.eof()) {
out.getline(s, 1000, '\n');
sscanf(s, "%d %s %d %s %s %s %s %s %d:%d:%d", &id, &name, &problem, &state, &L[0], &L[1], &L[2], &tmp, &now.hour, &now.minutes, &now.seconds);
for (int i = 0; i < n; i++) {
if (pro[i] == problem) {
num = i;
break;
}
}
pid = -1;
for (int i = 0; i < nn; i++) {
if (strcmp(team[i].name, name) == 0) {