import java.util.*;
class main {
public static void main
(String[] args
) { Scanner scanner
= new Scanner
(System.
in); int t = scanner.nextInt();
StringBuilder result = new StringBuilder();
while (t-- > 0) {
int n = scanner.nextInt();
int k = scanner.nextInt();
int[] prices = new int[n];
for (int i = 0; i < n; i++) {
prices[i] = scanner.nextInt();
}
long[] prefixSum = new long[n + 1];
for (int i = 0; i < n; i++) {
prefixSum[i + 1] = prefixSum[i] + prices[i];
}
long[] minCost = new long[n + 1];
for (int m = 1; m <= n; m++) {
minCost[m] = prefixSum[m];
if (m > k) {
minCost
[m
] = Math.
min(minCost
[m
], minCost
[m
- k
- 1] + prefixSum
[m
] - prefixSum
[m
- k
]); }
}
for (int m = 1; m <= n; m++) {
result.append(minCost[m]).append(" ");
}
result.append("\n");
}
System.
out.
println(result.
toString()); }
}
aW1wb3J0IGphdmEudXRpbC4qOwpjbGFzcyBtYWluIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBTY2FubmVyIHNjYW5uZXIgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIGludCB0ID0gc2Nhbm5lci5uZXh0SW50KCk7IAoKICAgICAgICBTdHJpbmdCdWlsZGVyIHJlc3VsdCA9IG5ldyBTdHJpbmdCdWlsZGVyKCk7CgogICAgICAgIHdoaWxlICh0LS0gPiAwKSB7CiAgICAgICAgICAgIGludCBuID0gc2Nhbm5lci5uZXh0SW50KCk7IAogICAgICAgICAgICBpbnQgayA9IHNjYW5uZXIubmV4dEludCgpOyAKICAgICAgICAgICAgaW50W10gcHJpY2VzID0gbmV3IGludFtuXTsKCiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgICAgICAgICBwcmljZXNbaV0gPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgQXJyYXlzLnNvcnQocHJpY2VzKTsKCiAgICAgICAgICAgIGxvbmdbXSBwcmVmaXhTdW0gPSBuZXcgbG9uZ1tuICsgMV07CiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgICAgICAgICBwcmVmaXhTdW1baSArIDFdID0gcHJlZml4U3VtW2ldICsgcHJpY2VzW2ldOwogICAgICAgICAgICB9CgogICAgICAgICAgICBsb25nW10gbWluQ29zdCA9IG5ldyBsb25nW24gKyAxXTsKICAgICAgICAgICAgZm9yIChpbnQgbSA9IDE7IG0gPD0gbjsgbSsrKSB7CiAgICAgICAgICAgICAgICBtaW5Db3N0W21dID0gcHJlZml4U3VtW21dOwogICAgICAgICAgICAgICAgaWYgKG0gPiBrKSB7CiAgICAgICAgICAgICAgICAgICAgbWluQ29zdFttXSA9IE1hdGgubWluKG1pbkNvc3RbbV0sIG1pbkNvc3RbbSAtIGsgLSAxXSArIHByZWZpeFN1bVttXSAtIHByZWZpeFN1bVttIC0ga10pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CgogICAgICAgICAgICBmb3IgKGludCBtID0gMTsgbSA8PSBuOyBtKyspIHsKICAgICAgICAgICAgICAgIHJlc3VsdC5hcHBlbmQobWluQ29zdFttXSkuYXBwZW5kKCIgIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVzdWx0LmFwcGVuZCgiXG4iKTsKICAgICAgICB9CgogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihyZXN1bHQudG9TdHJpbmcoKSk7CiAgICB9Cn0=