#include <stdio.h>
#include <ctype.h>

void main(), put_entry() ;
char *get_entry() ;

void main()
{
	char one_entry[BUFSIZ], two_entry[BUFSIZ] ;
	char one_num[BUFSIZ], two_num[BUFSIZ] ;

	while( get_entry(one_entry, one_num) != NULL )
	{
redo:	if( get_entry(two_entry, two_num) == NULL )
		{
			put_entry(one_entry, one_num) ;
			continue ;
		}

		if( strcmp(one_entry, two_entry) )
		{
			put_entry(one_entry, one_num) ;
			strcpy(one_entry, two_entry) ;
			strcpy(one_num, two_num) ;
		}
		else
		{
			strcat(one_num, ",") ;
			strcat(one_num, two_num) ;
		}

		goto redo ;
	}
}


char *get_entry(entry, num)
char *entry, *num ;
{
	char *ptr, line[BUFSIZ] ;

	if( gets(line) == NULL ) return NULL ;
	else ptr = line ;

	while( isdigit(*ptr) ) *num++ = *ptr++ ;
	*num = NULL ;

	while( isspace(*ptr) ) ptr++ ;

	strcpy(entry, ptr) ;

	ptr = entry + strlen(entry) -1 ;
	while( isspace(*ptr) ) ptr-- ;
	*(ptr+1) = NULL ;


	return entry ;
}

void put_entry(entry, num)
char *entry, *num ;
{
	printf(".EI \"%s\" \"%s\"\n", entry, num) ;
}
