#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

map< int, int > ref_counts;
map< string, vector< int > > chemicals;

int main()
{
	string input;
//	freopen( "file_name", "rb", stdin );
	while( getline( std::cin, input ) )
	{
		vector< int > ids;
		for( int pos = 0; pos < input.length(); ++pos )
		{
			if( input[pos] <= '9' && input[pos] >= '0' )
			{
				int number = 0;
				for( ; input[ pos ] > ' '; ++pos ) // replace to '\t'
					number = number * 10 + ( input[ pos ] - '0' );
				ids.push_back( number );
				ref_counts[ number ]++;
			}
			else if( input[pos] >= '_' )
			{
				string kind_name = input.substr( pos, input.length() - pos );
				chemicals[ kind_name ] = ids;
				break;
			}
		}
	}
	for( const auto& c : chemicals )
	{
		cout << c.first << " : ";
		for( const auto& i : c.second )
			printf( "%07u ", i );
		cout << endl;
	}
	cout << endl;
	for( const auto& r : ref_counts )
		printf( "%07u : %5u\n", r.first, r.second );
	return 0;
}