407762: GYM102890 M Mathematics society problem
Description
Nlogonia secret mathematics society helds meetings with distinguished members that are able to solve a given mathematical problem. Being one of the most prestigious mathematics societies in the region you want to participate in the meeting, they discuss in this meetings a lot of interesting problems and their solutions, and therefore, it could be also a very good place to train your algorithmic skills.
The problem to be invited to the next meeting has been posted, last month meeting they used an interesting problem that generated long lists of numbers. This time, they want you to work with some of these numbers. They will give you a number $$$N$$$ that contains only digits from $$$1$$$ to $$$9$$$, your task is to remove a specified amount of each digit from $$$N$$$ and get the biggest possible number. Will you be able to join this month meeting?
InputThe first line of input contains a number $$$N$$$, $$$N$$$ will have at most $$$1000$$$ digits. The second and last line of input contains $$$9$$$ integer numbers separated by a space, where the $$$i$$$-th number represents the amount of times the digit $$$i$$$ should be removed from $$$N$$$. It is guaranteed that no digit should be removed more times than it appears in $$$N$$$, and that in no case all digits from $$$N$$$ should be removed.
OutputOutput a line containing a number, representing the biggest number you can get after removing the specified digits from $$$N$$$.
ExamplesInput12345 1 0 0 1 1 0 0 0 0Output
23Input
112345 2 1 1 0 0 0 0 0 0Output
45Input
54321 0 0 0 0 0 0 0 0 0Output
54321