123 - Searching Quickly

給你一組標題字串,並告訴你那些是相對不重要的字,請你寫一個程式找出標題字串中所有關鍵字(Key Word In Context),並依照關鍵字的字典順序依序列出。

關鍵字是除了所有不重要的字以外的字,而我們會給你那些不重要的字。

例如,不重要的字若為:``the, of, and, as, a’’,且有四組標題列:

Descent of Man
The Ascent of Man
The Old Man and The Sea
A Portrait of The Artist As a Young Man

而我們需要你依字典順序找出所有關鍵字後,把整個標題列出,並把關鍵字改為大寫:

                      a portrait of the ARTIST as a young man
                              the ASCENT of man
                                  DESCENT of man
                       descent of MAN
                    the ascent of MAN
                          the old MAN and the sea
a portrait of the artist as a young MAN
                              the OLD man and the sea
                                a PORTRAIT of the artist as a young man
              the old man and the SEA
    a portrait of the artist as a YOUNG man

Input

輸入的每一列都是一筆資料,上半部會給你所有「不重要的字」,下半部會給你所有標題列,中間以雙冒號(::)隔開,「不重要的字」會以英文小寫的型式出現,每一列都表示一個字,最多不會超過10個字元。而標題列也是一列表示一個標題,但是會有大小寫混合,標題中的字會以空白字元隔開,裡面的字最多15個字元。

「不重要的字」最多50個,標題列最多200個,輸入資料的總字元數則不超過10,000個,除了英文大小寫(‘a’-‘z’, ‘A’-‘Z’)及空白字元外,不會出現其他字元。

Output

我們的目的是找出所有標題列中所有關鍵字(即扣除那些不重要的字),但並非只把關鍵字列出即可,請列出整列標題。並以關鍵字的字典順序依序列出,如果標題內有多個相同的關鍵字,則亦必需重複列出此標題。

所列出的標題中的關鍵字必須改為全大寫,而其他字則必須全小寫。不同標題若有相同的關鍵字,請依標題輸入的順序列出,同一標題內重複出現的關鍵字之輸出順序,請以由左到右的原則來做輸出。

判繼哪些是「不重要的字」時,請無視大小寫的差異。

輸出整列標題時不需要有多餘的空白字元,請勿依關鍵字向左或向右對齊,格式如下所示。

Sample Input

is
the
of
and
as
a
but
::
Descent of Man
The Ascent of Man
The Old Man and The Sea
A Portrait of The Artist As a Young Man
A Man is a Man but Bubblesort IS A DOG

Sample Output

a portrait of the ARTIST as a young man
the ASCENT of man
a man is a man but BUBBLESORT is a dog
DESCENT of man
a man is a man but bubblesort is a DOG
descent of MAN
the ascent of MAN
the old MAN and the sea
a portrait of the artist as a young MAN
a MAN is a man but bubblesort is a dog
a man is a MAN but bubblesort is a dog
the OLD man and the sea
a PORTRAIT of the artist as a young man
the old man and the SEA
a portrait of the artist as a YOUNG man