#P3752. Language Identification in Yugo Nation
Language Identification in Yugo Nation
Language Identification in Yugo Nation
In Yugo Nation, many races speak different languages. The chairman has provided you with several dictionaries mapping words to languages. Your task is to determine the language of given sentences.
For each sentence, count how many words from each language's dictionary appear in the sentence (matching is case-insensitive and words are separated by non-alphabetical characters). Each sentence is guaranteed to have exactly one language with the maximum count.
The dictionaries and sentences are provided in the input. When counting, make sure to convert words to lowercase and use LaTeX formatted expressions if needed (for instance, you may refer to the count as \(count\)).
inputFormat
The first line contains an integer \(L\) (1 ≤ \(L\) ≤ 20) – the number of languages. For each language, there are two lines:
- A line containing the language name and an integer \(K\) (1 ≤ \(K\) ≤ 100) – the number of words in that language's dictionary.
- A line with \(K\) distinct words separated by spaces (all in lowercase).
After describing all languages, there is a line with an integer \(S\) (1 ≤ \(S\) ≤ 50) – the number of sentences. Then \(S\) lines follow, each containing a sentence that may include words in mixed case. Non-alphabetical characters serve as delimiters.
outputFormat
For each sentence, output the language that the sentence most likely belongs to on a separate line. Matching is done in a case-insensitive manner.
sample
3
English 3
hello world language
Spanish 3
hola mundo idioma
French 3
bonjour monde langue
3
Hello, world! This is a test.
¡Hola! ¿Cómo está el mundo?
Bonjour, le monde merveilleux.
English
Spanish
French
</p>