#K42382. Autocomplete Function

    ID: 27075 Type: Default 1000ms 256MiB

Autocomplete Function

Autocomplete Function

This problem tasks you with implementing an autocomplete feature. Given a list of words and a prefix, you are to output all words from the list that start with the given prefix. The matching is case-sensitive.

Input Format: The first line contains an integer \(n\) (\(1 \leq n \leq 10^5\)) representing the number of words. This is followed by \(n\) lines each containing a non-empty word. The final line contains the prefix string.

Output Format: For each word in the order provided that begins with the given prefix, output the word on a new line. If no words match, output nothing.

Note that the condition for checking the prefix can be represented as \( \text{word.startswith(prefix)} \). Efficiency and simplicity are key in this task.

inputFormat

The input is read from standard input (stdin) and follows this format:

  1. An integer \(n\) representing the number of words.
  2. \(n\) lines each containing a single word.
  3. A line containing the prefix string.

outputFormat

Output each word that starts with the provided prefix on its own line in the order they appear in the input. If no words start with the given prefix, no output should be produced.

## sample
5
apple
ape
apricot
banana
bat
ap
apple

ape apricot

</p>