Serves Me Right

No attempts yetTime limit2sMemory limit256 MB

Problem

You look after a web server. Your company pays for NN concurrent licenses, so NN users can be logged in at the same time. The company is cutting costs everywhere, and your supervisor wants to know whether all NN licenses are really needed.

The server logs three kinds of events.

  • the time a user connects and a session starts
  • the time a user disconnects and the session is removed
  • the time the server restarts

Users do not always log out; some just close the browser. Each session therefore has a timeout of SS minutes. A session that starts at time tt ends at time t+St+S, and that user is already disconnected at t+St+S. The automatic disconnect is not logged.

If a user whose session is still open records another LOG_IN, the session starts again from that moment and ends SS minutes later.

When the server restarts, every user is disconnected at that moment and every session is removed.

You are given one day of server log and the session timeout. Report how many different users appear in the log, and the largest number of users logged in at the same time.

Input

The first line has one integer TT, the number of logs to process (1T1001 \le T \le 100).

Each log starts with a line holding the number of entries EE and the session timeout SS in minutes, separated by a space (1E,S14401 \le E, S \le 1440). Then follow EE lines, one entry each, in one of two forms:

TIME SERVER RESTART
TIME USER USER_NAME USER_ACTION

TIME is HH:MM on a 24 hour clock. USER_NAME is a string of 1 to 16 lowercase English letters, and the same name always means the same user. USER_ACTION is either LOG_IN or LOG_OUT. Entries come in increasing order of time, and all times inside one log are different. The log has no inconsistency: LOG_OUT appears only for a user whose session is open at that time. Not all NN users have to appear in the log.

Output

For each log, print the number of different users that appear in the log and the largest number of users logged in at the same time, separated by one space, on a single line.