


Input: 'S' = "babbc", 'COST' = [1, 2, 3, 4, 5]
Output: 3
By deleting the third letter 'b' with cost, 3 will transform the string into 'babc'. This is the minimum possible cost to transform the string.
The first line of input contains an integer 'T', denoting the number of test cases.
For each test case, the first line contains an integer 'N' second line contains a string of size 'N' and the last line contains the 'N' elements in the array 'COST'.
For each test case, print the minimum cost needed to transform the string.
Output for each test case will be printed in a separate line.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= ‘T’ <= 10
2 <= 'N' <= 10^4
1 <= 'COST[i]'<= 10^4
Time Limit: 1sec
We will pick the character with the maximum cost in the group to leave and then delete the rest of them.
Algorithm :