#C10357. Filter Words by Prefix

    ID: 39553 Type: Default 1000ms 256MiB

Filter Words by Prefix

Filter Words by Prefix

You are given a list of words and a prefix. Your task is to output all words from the list that start with the given prefix, preserving their original order.

A word w is said to start with prefix p if the first \( |p| \) characters of w are exactly p (i.e. \( w[0:|p|] = p \)).

If no words match the prefix, output an empty line.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. An integer N on the first line indicating the number of words.
  2. The next N lines each contain a single word.
  3. The last line contains the prefix string.

outputFormat

Print all words that start with the given prefix in one line, separated by a single space. If no words match, output an empty line.

## sample
6
apple
app
apricot
banana
grape
application
app
apple app application