You look after a web server. Your company pays for N concurrent licenses, so N users can be logged in at the same time. The company is cutting costs everywhere, and your supervisor wants to know whether all N licenses are really needed.
The server logs three kinds of events.
Users do not always log out; some just close the browser. Each session therefore has a timeout of S minutes. A session that starts at time t ends at time t+S, and that user is already disconnected at t+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 S 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.
The first line has one integer T, the number of logs to process (1≤T≤100).
Each log starts with a line holding the number of entries E and the session timeout S in minutes, separated by a space (1≤E,S≤1440). Then follow E 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 N users have to appear in the log.
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.