Wikipedia#4521

Wikipedia

1 second
64 megabytes
Easy

Petya, inspired by the success of Wikipedia, decided to create a similar encyclopedia on his homepage. As he is learning English, he opted to make the encyclopedia in English.

To begin, Petya transcribed several texts from the Encyclopedia Britannica. Now, he wants to insert links to other articles within these texts. Given the large number of articles, he decided to automate this process.

In a wiki page, a link to an article is formatted as:

For example, in the sentence

\text{In the wild cats are often enemies of }[[\text{Dog}|\text{dogs}]]

the word dogs is a link to the article Dog. If the article title is the same as the link text, the link can be formatted simply as:

For instance, in the sentence

\text{Growing together a }[[\text{dog}]]\text{ and a cat can often be friends}

the word dog links to the article dog. In this case, the case of the first letter in article titles is ignored, but the case of other letters is significant. Therefore, the word dog can link to the article Dog, but DOG cannot.

Your task is to help Petya insert links on his site. The site consists of a set of articles, each with a title—a single word—and some text. For each title word, all its word forms and synonyms are known.

A word in the text is defined as a sequence of English alphabet letters, bounded by non-letter characters, or by the start or end of a line. In the article text, you need to find all words that are word forms or synonyms of the titles of other articles and convert them into wiki links.

Input

The first line of the input file contains the number —the number of articles in Petya's Wikipedia (2 \leq n \leq 50). Then follow the descriptions of the articles.

Each article description begins with a line containing the article's title. The next line contains a number —the number of word forms and synonyms for the article title (1 \leq k \leq 10). The following lines each contain one word—word forms and synonyms for the current article title. Then there is a line with the number —the number of lines in the article text (1 \leq l \leq 10). This is followed by the article text— lines, each no longer than characters.

All article titles are unique. All word forms and synonyms of all titles are distinct and different from the article titles.

All words consist of Latin letters; each word in the input file does not exceed characters. The input file contains only spaces, line breaks, and characters with ASCII codes from to .

Output

Output the articles with links inserted. Present the articles as follows: output the article title first. Then output the article text, maintaining the line breaks as in the input file. Convert all words in the text that match the title of another article or a word form or synonym of another article into links. When comparing words, ignore the case of the first letter, but respect the case of the others. Words that match the article title should be converted to the short version of the link; others should be converted to the full version.

Examples

Example 1

Loading
Loading