CF1311C Perform the Combo
Description
You want to perform the combo on your opponent in one popular fighting game. The combo is the string $ s $ consisting of $ n $ lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in $ s $ . I.e. if $ s= $ "abca" then you have to press 'a', then 'b', 'c' and 'a' again.
You know that you will spend $ m $ wrong tries to perform the combo and during the $ i $ -th try you will make a mistake right after $ p_i $ -th button ( $ 1 \le p_i < n $ ) (i.e. you will press first $ p_i $ buttons right and start performing the combo from the beginning). It is guaranteed that during the $ m+1 $ -th try you press all buttons right and finally perform the combo.
I.e. if $ s= $ "abca", $ m=2 $ and $ p = [1, 3] $ then the sequence of pressed buttons will be 'a' (here you're making a mistake and start performing the combo from the beginning), 'a', 'b', 'c', (here you're making a mistake and start performing the combo from the beginning), 'a' (note that at this point you will not perform the combo because of the mistake), 'b', 'c', 'a'.
Your task is to calculate for each button (letter) the number of times you'll press it.
You have to answer $ t $ independent test cases.
Input Format
N/A
Output Format
N/A
Explanation/Hint
The first test case is described in the problem statement. Wrong tries are "a", "abc" and the final try is "abca". The number of times you press 'a' is $ 4 $ , 'b' is $ 2 $ and 'c' is $ 2 $ .
In the second test case, there are five wrong tries: "co", "codeforc", "cod", "co", "codeforce" and the final try is "codeforces". The number of times you press 'c' is $ 9 $ , 'd' is $ 4 $ , 'e' is $ 5 $ , 'f' is $ 3 $ , 'o' is $ 9 $ , 'r' is $ 3 $ and 's' is $ 1 $ .