#C2205. Autocomplete Prefix Matching

    ID: 45496 Type: Default 1000ms 256MiB

Autocomplete Prefix Matching

Autocomplete Prefix Matching

You are given two lists: a list of words and a list of prefixes. Your task is to, for each prefix, output all the words (in the order they appear in the word list) that start with that prefix.

If no word in the list begins with a given prefix, output No match found for that prefix.

The input is given via stdin and the output should be printed to stdout. The input format is described in the Input section.

Note: The matching is case-sensitive.

inputFormat

The first line contains an integer n which represents the number of words.

The second line contains n space-separated words.

The third line contains an integer m representing the number of prefixes.

The fourth line contains m space-separated prefixes.

outputFormat

For each prefix in the order given, output each word from the original word list that starts with the prefix on a separate line, preserving their original order.

If none of the words start with a prefix, print No match found on a separate line for that prefix.

## sample
5
apple app application banana band
3
app ban cat
apple

app application banana band No match found

</p>