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

Задача 38790. Dormitory pass - 1


Задача

Темы: Словари
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 for entry and two times in a row for 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 as infringers those passholders who have three login-logout-login events 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 chosen by the head of security, respectively (1≤n≤1000, 3≤dt≤1440).
The next nn lines give entries in the event log in chronological order. The log entry consists of three parts, separated by a space:
  •  Event time in hh:mm format
  •  Student's last name, consisting of no more than 20 letters of the Latin alphabet, 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 offenders. 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
Petrov
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