A table tennis club has 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_堆 tables available to the public. The tables are numbered from 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_pat甲级_02 to 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_堆. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the smallest number. If all the tables are occupied, they will have to wait in a queue. It is assumed that every pair of players can play for at most 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_pat甲级_04 hours.

Your job is to count for everyone in queue their waiting time, and for each table the number of players it has served for the day.

One thing that makes this procedure a bit complicated is that the club reserves some tables for their 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_字符串_05 members. When a VIP table is open, the first 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_字符串_05 pair in the queue will have the privilege to take it. However, if there is no 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_字符串_05 in the queue, the next pair of players can take it. On the other hand, if when it is the turn of a VIP pair, yet no 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_字符串_05 table is available, they can be assigned as any ordinary players.

Input Specification:
Each input file contains one test case. For each case, the first line contains an integer ​​​N​​​ 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_pat甲级_09 - the total number of pairs of players. Then 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_堆 lines follow, each contains 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_pat甲级_04 times and a 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_字符串_05 tag: ​​​HH:MM:SS​​​ - the arriving time, ​​P​​​ - the playing time in minutes of a pair of players, and tag - which is 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_pat甲级_02 if they hold a 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_字符串_05 card, or 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_pat甲级_15 if not. It is guaranteed that the arriving time is between ​​​08:00:00​​​ and ​​21:00:00​​​ while the club is open. It is assumed that no two customers arrives at the same time. Following the players’ info, there are 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_pat甲级_04 positive integers: ​​​K​​​ 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_毒瘤题_17 - the number of tables, and 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_pat甲级_18 - the number of VIP tables. The last line contains 【PAT (Advanced Level) Practice】1026 Table Tennis (30 分)_#include_19 table numbers.

Output Specification:
For each test case, first print the arriving time, serving time and the waiting time for each pair of players in the format shown by the sample. Then print in a line the number of players served by each table. Notice that the output must be listed in chronological order of the serving time. The waiting time must be rounded up to an integer minute(s). If one cannot get a table before the closing time, their information must NOT be printed.

Sample Input:

10
20:52:00 10 0
08:00:00 20 0
08:02:00 30 0
20:51:00 10 0
08:10:00 30 0
08:12:00 10 1
20:40:00 13 0
08:01:30 15 1
20:53:00 10 1
20:54:00 10 0
3 1
2

Sample Output:

08:00:00 08:00:00 0
08:01:30 08:01:30 0
08:02:00 08:02:00 0
08:12:00 08:16:30 5
08:10:00 08:20:00 10
20:40:00 20:40:00 0
20:51:00 20:51:00 0
20:52:00 20:52:00 0
20:53:00 20:53:00 0
4 3 2

#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

const int N = 10010, M = 110, INF = 1000000;

int n, k, m;

struct Person{ // 球员

int arrive_time, play_time;
int start_time, waiting_time;

bool operator < (const Person & t) const{ // sort 排序
if(start_time != t.start_time) return start_time < t.start_time;
return arrive_time < t.arrive_time;
}
bool operator > (const Person & t) const{ // 优先队列中比较大小
return arrive_time > t.arrive_time;
}
};

struct Table{ // 球桌

int id;
int end_time;

bool operator > (const Table & t) const{
if(end_time != t.end_time) return end_time > t.end_time;
return id > t.id;
}
};

bool is_vip_table[M];
int table_cnt[M];

vector<Person> persons;

void assign(priority_queue<Person, vector<Person>, greater<Person>> &ps,
priority_queue<Table, vector<Table>, greater<Table>> &ts)
{

auto p = ps.top(); ps.pop();
auto t = ts.top(); ts.pop();

p.waiting_time = round((t.end_time - p.arrive_time) / 60.0);
p.start_time = t.end_time;
table_cnt[t.id]++;
persons.push_back(p);
ts.push({t.id, t.end_time + p.play_time});
}

string get_time(int secs){
char str[20];
sprintf(str, "%02d:%02d:%02d", secs / 3600, secs % 3600 / 60, secs % 60);
return str;
}

int main(){

cin >> n;

priority_queue<Person, vector<Person>, greater<Person>> normal_persons, vip_persons;

normal_persons.push({INF});
vip_persons.push({INF});

for(int i = 0; i < n; i++){

int hour, minute, second;
int play_time, is_vip;
scanf("%d:%d:%d %d %d", &hour, &minute, &second, &play_time, &is_vip);

int secs = hour * 3600 + minute * 60 + second;
play_time = min(play_time, 120);
play_time *= 60;

if(is_vip) vip_persons.push({secs, play_time});
else normal_persons.push({secs, play_time});
}

priority_queue<Table, vector<Table>, greater<Table>> normal_tables, vip_tables;

normal_tables.push({-1, INF});
vip_tables.push({-1, INF});

cin >> k >> m;
for(int i = 0; i < m; i++){

int id;
cin >> id;
is_vip_table[id] = true;
}

for(int i = 1; i <= k; i++)
if(is_vip_table[i]) vip_tables.push({i, 8 * 3600});
else normal_tables.push({i, 8 * 3600});

while(normal_persons.size() > 1 || vip_persons.size() > 1){

auto np = normal_persons.top();
auto vp = vip_persons.top();
int arrive_time = min(np.arrive_time, vp.arrive_time);

while(normal_tables.top().end_time < arrive_time){ // O(klok)

auto t = normal_tables.top();
normal_tables.pop();
t.end_time = arrive_time;
normal_tables.push(t);
}

while(vip_tables.top().end_time < arrive_time){

auto t = vip_tables.top();
vip_tables.pop();
t.end_time = arrive_time;
vip_tables.push(t);
}

auto nt = normal_tables.top();
auto vt = vip_tables.top();

int end_time = min(nt.end_time, vt.end_time);

if(end_time >= 21 * 3600) break;

if(vp.arrive_time <= end_time && vt.end_time == end_time) assign(vip_persons, vip_tables);
else if(np.arrive_time < vp.arrive_time){

if(nt > vt) assign(normal_persons, vip_tables);
else assign(normal_persons, normal_tables);
}else{

if(nt > vt) assign(vip_persons, vip_tables);
else assign(vip_persons, normal_tables);
}
}

sort(persons.begin(), persons.end());

for(auto &person: persons){

cout << get_time(person.arrive_time) << ' ' << get_time(person.start_time) << ' ';
cout << person.waiting_time << endl;
}

cout << table_cnt[1];
for(int i = 2; i <= k; i++) cout << ' ' << table_cnt[i];
cout << endl;

return 0;
}