2007/2008 SOUTHERN CALIFORNIA REGIONAL
ACM INTERNATIONAL COLLEGIATE PROGRAMMING CONTEST

Problem 2
Document Archives

You work for an insurance company and your group handles the saving and archiving of all customer correspondence. Each piece of correspondence (letter, FAX, e-mail message, etc.) is scanned and/or saved into a scanning system that archives the document into a database. Because your company has so many saved documents, an index of saved documents was created to find each document quickly.
The layout of the index file is as follows. Fields are separated from each other by single colons, lines are separated by newline characters, and the file is stored as simple text.
< Document ID > : < Document Type > : < Participant ID > : < Size of document in bytes > : < Saved Date >
Where:
< Document ID > = a 15 digit number (possibly including leading zeroes)
< Document Type > = a 3 digit number representing the type of document (possibly including leading zeroes)
< Participant ID > = a 9 digit number to identify the participant (possibly including leading zeroes)
< Size of document in bytes > = size of the document in bytes, with a maximum size of 100,000 bytes
< Saved Date > = date document was saved in the database, in the following format: dd-mm-yyyy, where dd is 01-31, mm is 01-12, and yyyy is a four-digit year
It is possible for the same document to be scanned multiple times; therefore a given Document ID may appear more than once in the index. Each such instance is to be treated as a separate document.
Your team is to write a program to read this index file from standard input and produce a summary report containing the the number of documents of each Document Type per Participant ID. There will be no more than 1000 lines in the index.
The report is to contain one line per Participant ID and Document Type. Each line is to contain the Participant ID, a single space, the Document Type, a single space, and the number of documents. There should be no leading or trailing whitespace. The Participant ID and Document Type are to appear as they do in the input. The number of documents is to be printed as an unsigned integer without leading zeroes. The report is to be sorted by Participant ID in ascending order, and within Participant ID by Document Type in ascending order.


Sample Input

 765543897654321:019:887341154:54389:05-07-2007
 817264098334611:188:899123345:76555:01-01-2006
 234871243098738:019:887341154:77489:02-05-2007
 282349823498234:288:887341154:98344:02-09-2007


Output for the Sample Input

 887341154 019 2
 887341154 288 1
 899123345 188 1



File translated from TEX by TTH, version 3.77.
On 18 Nov 2007, 09:05.