People think that $$$\textit{Somar}$$$ likes palindrome strings, but actually, palindrome strings mean to $$$\textit{Somar}$$$ more than his own life. That's why he always searches for them around the world.
The problem is that a palindrome string is a rare element in nature. Therefore, to obtain a palindrome string, you need to extract it from a normal string (which may or may not be a palindrome) through a difficult process. Of course, $$$\textit{Somar}$$$ is busy and needs your help to extract palindrome strings.
You will be given an array $$$w$$$ consisting of $$$n$$$ strings, each string associated with a score $$$s_i$$$.
You can perform the following operation at most $$$k$$$ times:
Your goal is to find the maximum possible score of a beautiful subarray in $$$w$$$, if you can perform the previous operation no more than $$$k$$$ times.
The first line contains an integer $$$t$$$ $$$(1 \le t \le 10^5)$$$ — the number of test cases. The descriptions of the test cases follow.
For each test case, the first line contains two integers $$$n$$$ and $$$k$$$ $$$(1 \le n \le 10^5, 0 \le k \le 10^9)$$$.
The next $$$n$$$ lines each contain a string $$$w_i$$$ $$$(1 \le |w_i| \le 5\times 10^5)$$$.
The next line contains $$$n$$$ integers $$$s_1, s_2, \dots, s_n$$$ $$$(-10^9 \le s_i \le 10^9)$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$, and the sum of $$$|w_i|$$$ over all test cases does not exceed $$$5\times 10^5$$$.
For each test case, print one integer: the maximum possible score of a beautiful subarray in $$$w$$$, if you can perform the allowed operation no more than $$$k$$$ times.
36 7youstilldontknowmeyet3 12 -1 -2 9 23 12codeforcescodeblockswronganswer-2 -1 -13 2ffteedepeetreee3 4 5
18 0 5
in the first test case: change the second string to stits. change the third string to toot. change the fourth string to kook. change the fifth string to ee. so the answer will be: 12-1-2+9 = 18.
| Название |
|---|


