Charity Begins at Home-page

Time Limit: 5 Seconds    Memory Limit: 32768 KB

Dozens of charity WWW sites have appeared recently. These sites donate advertising payments they receive to charitable organizations. But advertisers don't want to pay for people who come to the WWW site dozens of time a day, so require a list of unique visitors to the site. Some sites, such as The Hunger Site (, the original "Click for Charity" site, allow only one donation per address per day. Others, such as the Meals On Wheels site (, allow donations as frequently as every 6 hours.

You are to write a program to take a list of visits for a month and list the visitors to the site and the number of visits, both valid and invalid, they made in that month.


The input data file contains zero or more records of visitors to a charity WWW site, where each record appears on single line. Each visit will be in the following format:



dd is an integer that represents the day of the visit, with 01 <= dd <= 32
hh is an integer that represents the hour of the visit, with 00 <= hh <= 23
mm is an integer that represents the minute of the visit, with 00 <= mm <= 59
ss is an integer that represents the second of the visit, with 00 <= ss <= 59
address is a string that represents the email address of the visitor. The address will consist of the upper and lower case letters, digits, periods ('.'), and the at sign ('@') only. It will have exactly one '@' in it (that will not be the first character) and at least one period after the '@'. The '@' and '.' will not appear next to each other. An address will not end with a '.'. There will be at most 65 characters in the address. Case is not significant in addresses, so a@b.c and A@B.C should be considered to be the same address.

The visits will be arranged in time order, from earliest to latest. While there may be two or more visits at a given time, there will not be two visits for the same address at the same time.

There will be at most 1000 unique addresses in the input file.

The end of input will be indicated by an entry for day 32. This line should not be processed.


Output the number of valid and invalid visits for each address in the file. A visit is valid if it is the first visit in the file for the address or if it is 6 hours or more since the most recent previous valid visit for that address. A visit is invalid if it is not valid (that is, if it is less than 6 hours since the last valid visit for that email address in the file).

Output should be grouped by top-level domain, and within a top-level domain by the second-level domain. The top-level domain of the address is the character or characters after the last period in the address. The second-level domain is the collection of letters and digits immediately before the last period. For example, the address has the top-level domain edu and the second-level domain gcsu . Top-level domains should be alphabetized, then the second-level domains alphabetized under them. For each second-level domain, all the donors in that domain should be listed in ASCII order of address, followed by the number of valid donations(right-justified to column 69) and invalid donations(right justified to column 73). There should be one blank line between second-level domains and two blank lines between top-level domains. Use the format in the sample output.

All email addresses in the output should be in lower case.

Sample Input

Sample Output

Second level domain = disney 1 0

Second level domain = gcsu 3 1

Second level domain = mercer 3 0 1 0

Second level domain = ucf 1 1

Second level domain = usa 2 0

Second level domain = cbs 2 0

Source: Southeast USA 2000