Back To School '19: H🅰️r🅰️mbe

View as PDF

Submit solution


Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Emily is writing an English essay. She wants to make her essay sound more attractive, so she decides to replace some words with other words. However, she has already hit her character limit on her essay exactly, so the word she will replace with must be less than or equal to the length of the word that she replaces. Because Emily is a [wannabe] perfectionist, she wants her essay to be as close to the character limit as possible by choosing a word that is as close to the length of the original word as possible.

Currently, she is focusing on one word in particular and has created a list of substitute words that she feels will make her essay sound more attractive.

Can you help her decide which word to use?

Input Specification

The first line will contain the integer N (1 \le N \le 100), the number of substitute words.
The second line will contain N space-separated strings, the substitute words.
The last line will contain one string, the word to replace.

All words will only consist of lowercase letters and will be at most 100 letters in length. Also, there will be no "blank" (zero-length) words. The substitute words will each have a unique length.

Output Specification

Output the word Emily should replace with, satisfying the constraints described above. It is guaranteed that there will be at least one word.

Sample Input 1

3
derek dereck dereccc
winnie

Sample Output 1

dereck

Sample Input 2

1
ehh
thing

Sample Output 2

ehh

Sample Input 3

3
i am ironman
ironmaniam

Sample Output 3

ironman

Comments

There are no comments at the moment.