Integers
시간 제한2초메모리 제한512 MB
문자열과 인덱스 수열 t가 주어질 때, t에 대응하는 문자들을 부분수열로 포함하면서 사전순으로 가장 작은 문자열의 부분수열을 구한다.
문제
You are given a string of length .
A sequence of integers is an index sequence if , where is the length of .
A string corresponding to an index sequence is the the following string: . Note that it is always a subsequence of .
You are given an index sequence. Find the lexicographically smallest string which corresponds to some index sequence which contains the given one as a subsequence.
입력
The first line contains the string consisting of () lowercase English letters.
The second line contains a single integer (), length of .
The third line contains integers (). is an index sequence.
출력
Print a single string --- the answer to the problem.