You are given a string of length
and
queries. For each query you must print the shortest string that starts with a character
and ends with a character
that only has adjacent characters that are found in
.
For example, if is "ajba", then pairs of adjacent letters in your resulting string can only be "aj", "jb", or "ba". Note that "ja" would not be allowed.
If there are multiple answers, print the lexicographically least.
If there is no such string, print -.
Input Specification
The first line will contain two integers
and
The second line will contain the string of length
containing only lowercase English letters.
Lines to
will contain two lowercase English letters
and
,
Output Specification
One line per query, the shortest string or - if none exist.
Sample Input 1
6 2
mcpttq
m t
p q
Sample Output 1
mcpt
ptq
Comments