시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB588714.000%

문제

You are given a string $s$ of length $n$.

A sequence of integers $t$ is an index sequence if $1 \leq t_1 < t_2 < \ldots < t_k \leq n$, where $k$ is the length of $t$.

A string corresponding to an index sequence $t$ is the the following string: $s_{t_1} s_{t_2} \ldots s_{t_k}$. Note that it is always a subsequence of $s$.

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 $s$ consisting of $n$ ($1 \leq n \leq 5 \cdot 10^5$) lowercase English letters.

The second line contains a single integer $k$ ($1 \leq k \leq n$), length of $t$.

The third line contains $k$ integers $t_i$ ($1 \leq t_i \leq n$). $t$ is an index sequence.

출력

Print a single string --- the answer to the problem.

예제 입력 1

links
2
3 4

예제 출력 1

ink

예제 입력 2

abacaba
2
4 6

예제 출력 2

aacab

예제 입력 3

pepega
2
2 6

예제 출력 3

ea

예제 입력 4

gaypride
2
6 7

예제 출력 4

aid

예제 입력 5

pogchamp
3
1 2 3

예제 출력 5

pog

예제 입력 6

frankerz
1
8

예제 출력 6

aerz

예제 입력 7

blessrng
8
1 2 3 4 5 6 7 8

예제 출력 7

blessrng

예제 입력 8

residentsleeper
4
1 3 7 15

예제 출력 8

resdeneeer