Eesti Vabariigi Aastapäev

Estonian flag raising at Toronto City Hall earlier today. Image source: Eesti Elu newspaper
February 24 is Eesti Vabariigi aastapäev, the 98th anniversary of Estonia's Declaration of Independence. So, today you'll help design a programme to look up Estonian words in a dictionary.

An Estonian noun has 28 forms, depending on what role it plays in a sentence. We'll just focus on the 14 singular forms and ignore the 14 plural forms. For example, the 14 singular forms of the word for "river" are:
1 jõgi the river (subject)
2 jõe of the river
3 jõge the river (partial object)
4 jõesse into the river
5 jões in the river
6 jõest out of the river
7 jõele onto the river
8 jõel on the river
9 jõelt off of the river
10 jõeks [becoming] a river
11 jõeni up to the river
12 jõena [acting] as a river
13 jõeta without the river
14 jõega with the river
The first three forms of a noun have to be memorized, but fortunately the other 11 forms are created in a systematic way by adding the endings -sse, -s, -st, -le, -l, -lt, -ks, -ni, -na, -ta, -ga to the second form. (There are some words that have irregular fourth forms, but let's ignore those.)

You will be given an Estonian-English dictionary, and a list of Estonian words to look up.

Input

The first line of the input will contain a positive integer n. Then there will be n lines, each containing 4 strings separated by a single space. Each of the n lines will contain an English noun, followed by the first three forms of an equivalent Estonian noun. Next, there will be a line containing a positive integer m. Then, there will be m lines, each containing a single Estonian noun in one of the 14 forms. To simplify input and output, we will omit accents on letters. Thus, õ and ö will be written as o, ä will be written as a, and ü will be written as u.

Output

For each of the m Estonian noun, you should output the corresponding English noun and the number of the form that it is in. If there is more than one match, you should output all of corresponding English words in alphabetical order, breaking ties by the form number. If the Estonian word does not appear in the dictionary, then you should output UNKNOWN. See below for the format of the output

Sample Input

5
river jogi joe joge
pig siga sea siga
car auto auto autot
rib rood roo roodu
reed roog roo roogu 
7
auto
autoga
siga
sealt
sigaks
roota
roogu

Sample Output

auto car 1
auto car 2
autoga car 14
siga pig 1
siga pig 3
sealt pig 9
sigaks UNKNOWN
roota reed 13
roota rib 13
roogu reed 3