#K57292. Autocomplete Suggestions

    ID: 30388 Type: Default 1000ms 256MiB

Autocomplete Suggestions

Autocomplete Suggestions

You are given a dictionary of words and a prefix. Your task is to implement an autocomplete feature by selecting from the dictionary all words that begin with the given prefix. The output should list the matching words sorted in alphabetical order.

Input Format: First line contains an integer n denoting the number of words in the dictionary. The second line contains n space-separated words representing the dictionary. The third line contains the prefix string.

Output Format: Print the words from the dictionary that begin with the given prefix in a single line, separated by a single space. If no words match the prefix, output an empty line.

Note: The matching is case sensitive, meaning uppercase and lowercase letters are treated as distinct.

inputFormat

The first line contains an integer n representing the number of words in the dictionary. The second line contains n words separated by spaces. The third line contains a single string representing the prefix.

outputFormat

Output a single line containing the autocomplete suggestions (the words that start with the given prefix) separated by a space, sorted in alphabetical order. If there are no matching words, output an empty line.

## sample
7
apple app apricot banana berry blueberry blackberry
ap
app apple apricot