#include <bits/stdc++.h>
using namespace std;
#define int long long int
//const int N = 1e5 + 10;
main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int sum1 = 0;
for (int i = 0; i < k; ++i) {
sum1 += a[i];
}
int ans = sum1;
for (int i = 1; i <= n - k; ++i) {
sum1 = sum1 - a[i - 1] + a[i + k - 1];
ans = min(ans, sum1);
for (int j = 0; j < k; ++j) {
for (int l = 0; l < i; ++l) {
int new_sum = sum1 - a[j] + a[l];
ans = min(ans, new_sum);
}
for (int l = i + k; l < n; ++l) {
int new_sum = sum1 - a[j] + a[l];
ans = min(ans, new_sum);
}
}
}
cout << ans << endl;
}
}