# Chefs Homework Dilemma Solution Codechef

Chef’s school semester lasts for  days. Chef’s teacher gives the students some homework every day and it is compulsory to turn in the homework by the very next day. Chef knows that the number of minutes needed to complete the homework on the -th day is .

Chef hates homework and wants to spend the minimum amount of time possible in doing homework. Luckily, he has a few tricks up his sleeve. Chef can hack the school records on any given day to make it show that the assigned homework is complete. However to avoid suspicion, Chef will not hack the records strictly more than  days consecutively.

Can you help Chef find the minimum possible total number of minutes that Chef needs to spend on homework?

Note:

• There are multiple test cases in a single file, refer to Input section for more details.
• Since the input is large, it is recommended to use fast input/output methods.

### Input Format

• The first line contains a single integer , the number of test cases. The description of the  test cases follow.
• The first line of each test case contains two integers  and  – the number of days in Chef’s semester and the maximum number of consecutive days Chef can hack the school’s record system.
• The second line of each test case contains  integers, , where  is the number of minutes Chef needs to complete the homework given on the -th day.

### Output Format

• For each test case, print a single line containing an integer, the minimum number of minutes Chef needs to spend on homework.

### Constraints

•  for all
• The sum of  over all test cases is at most

### Sample Input 1

3
7 3
213 124 156 263 149 6 62
7 1
476 457 232 130 849 95 749
7 2
601 35 45 304 449 452 190


### Sample Output 1

130
682
484


### Explanation

• In the first test case, Chef does his homework on days  and , taking a total of  minutes. The maximum number of consecutive days that Chef hacks is  (days , , and ), which is not more than .

• In the second test case, Chef does his homework on days , , and , taking a total of  minutes.

• In the third test case, Chef does his homework on days  and , taking a total of  minutes.

You can verify that these are indeed the optimal solutions.