Problem: You are given a long decimal number consisting of digits from to . You also have a function that maps every digit from to to some (possibly the same) digit from to .
You can perform the following operation no more than once: choose a non-empty contiguous subsegment of digits in , and replace each digit from this segment with . For example, if , , , , and you choose the segment consisting of three rightmost digits, you get as the result.
What is the maximum possible number you can obtain applying this operation no more than once?
Input Format: The first line contains one integer () — the number of digits in .
The second line contains a string of characters, denoting the number . Each character is a decimal digit from to .
The third line contains exactly integers , , ..., ().
Output Format: Print the maximum number you can get after applying the operation described in the statement no more than once.