Олимпиадный тренинг

Задача 38789. Dormitory pass - 2


Задача

Темы: Словари

There is a turnstile at the entrance to the hostel. To pass through it, you need to attach a pass. The pass must be applied both at the entrance to the hostel and at the exit from it. In order to exclude unauthorized passages, the pass does not work twice in a row to enter and twice in a row to exit.

However, cunning students figured out how to get around this limitation. To enter or exit together with one pass, they apply it from the right side, then from the opposite side, but no one passes, and then again from the right one.

The head of security decided to deal with this problem and reprimand all violators. Each login/logout event has an entry in the event log. It considers those pass holders who have three events of the form  exit-in-out in less than dt minutes.

You are given the turnstile event log. It is required to display a list of those students who will be reprimanded.

Input

The first line contains two numbers n and dt — the number of entries in the turnstile event log and the time limit selected by the head of security, respectively (1≤n≤1000, 3≤dt≤1440).

The following nn lines list the entries in the event log in chronological order. The log entry consists of three parts, separated by a space:

  • Event time in the format hh:mm
  • The student's last name, consisting of no more than 20 Latin letters, the first of which is capital.
  • Event type: in if logged in and out if logged out.

 

It is guaranteed that there are no two events that happen at the same time. It is also guaranteed that any two different students have different surnames and that one student does not have two events of the same type in a row.

Imprint

In the first line print the number of violators. Then print the last names of the offenders in lexicographical order.
 

Examples
# Input Output
1 6 10
01:23 Petrov in
01:24 Ivanov out
01:25 Petrov out
01:27 Ivanov in
01:32 Petrov in
01:33 Ivanov out
1
Ivanov
2 6 10
01:23 Petrov in
01:24 Ivanov out
01:25 Petrov out
01:27 Ivanov in
01:33 Petrov in
01:34 Ivanov out
0