#P1628. Prefix Word Filter

    ID: 14914 Type: Default 1000ms 256MiB

Prefix Word Filter

Prefix Word Filter

Given a list of \( N \) words and a string \( T \), your task is to output all the words that start with T in lexicographical order.

The criteria for a word to be included is that it has \( T \) as its prefix.

inputFormat

The first line contains an integer \( N \) indicating the number of words.

The following \( N \) lines each contain a single word.

The last line contains the string \( T \), which is the prefix to be matched.

outputFormat

Output all words that begin with prefix \( T \) in lexicographical order. Each word should be printed on a new line.

sample

4
apple
apricot
banana
pineapple
ap
apple

apricot

</p>