ACM Eastern European Regional Programming Contest.
Bucharest, Romania
October 19, 1996

Problem E
INDEXING

Input File Name: E.DAT

Program Source File: E.PAS or E.C or E.CPP


Consider several lines of text writen with capital letters and one character called KEY, specified on a line preceding the text. The words in the text are separated by spaces. There are no words splitted between two lines.

Write a program to display an index of all words within the text starting with the KEY. The index must be alphabetically sorted. Each word appears in the index only once and must be followed by the numbers of all the lines in which it appears. Only a single occurrence of each word on a line must be included in the index.


Example :


INPUT:


T

CONSIDER SEVERAL LINES OF TEXT AND ONE CHARACTER CALLLED KEY,

SPECIFIED ON A LINE PRECEDIING THE TEXT. THE WORDS IN THE TEXT ARE

SEPARATED BY SINGLE SPACE. THERE ARE NO WORDS SPLITTED BETWEEN TWO

LINES.

WRITE A PROGRAM TO DISPLAY AN INDEX OF ALL WORDS WITHIN THE TEXT

STARTING WITH THE KEY. THE INDEX MUST BE ALPHABETICALLY SORTED. EACH

WORD IN THE INDEX MUST BE FOLLOWED BY THE LIST OF THE LINE NUMBERS IN

WHICH IT APPEARS.


OUTPUT:


TEXT 1 2 5

THE 2 5 6 7

THERE 3

TO 5

TWO 3


Note:

maximum word length is <=80

line length is <=80