Codeforces Beta Round 49 (Div. 2)
A
Autocomplete
Codeforces
1100
原题
←B →
翻译中…

Autocomplete is a program function that enables inputting the text (in editors, command line shells, browsers etc.) completing the text by its inputted part. Vasya is busy working on a new browser called 'BERowser'. He happens to be working on the autocomplete function in the address line at this very moment. A list consisting of $*n*$ last visited by the user pages and the inputted part $*s*$ are known. Your task is to complete $*s*$ to make it an address of one of the pages from the list. You have to find the lexicographically smallest address having a prefix $*s*$.

翻译中…

Input

翻译中…

The first line contains the $*s*$ line which is the inputted part. The second line contains an integer $*n*$ ($1 ≤ *n* ≤ 100$) which is the number of visited pages. Then follow $*n*$ lines which are the visited pages, one on each line. All the lines have lengths of from $1$ to $100$ symbols inclusively and consist of lowercase Latin letters only.

翻译中…

Output

翻译中…

If $*s*$ is not the beginning of any of $*n*$ addresses of the visited pages, print $*s*$. Otherwise, print the lexicographically minimal address of one of the visited pages starting from $*s*$.

翻译中…

The lexicographical order is the order of words in a dictionary. The lexicographical comparison of lines is realized by the '<' operator in the modern programming languages.

翻译中…

样例

Input #1
next
2
nextpermutation
nextelement
Output #1
nextelement
InputCopy OutputCopy
Input #2
find
4
find
findfirstof
findit
fand
Output #2
find
InputCopy OutputCopy
Input #3
find
4
fondfind
fondfirstof
fondit
fand
Output #3
find
InputCopy OutputCopy
题目信息
题号
53A
时间限制
2 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。