def getmin(A, B, K):
A.sort()
B.sort(reverse=True)
sum_ = 0
for k in range(K):
if A and B and A[-1]>B[-1]:
sum_ += B[-1]
A.pop()
B.pop()
else:
break
sum_ += sum(A)
return sum_
for t in range(int(input())):
N, K = map(int, input().split())
X = list(map(int, input().split()))
best = 10**9
for i in range(N):
for j in range(i, N):
inside, outside = [], []
for k in range(N):
if i<=k and k<=j:
inside.append(X[k])
else:
outside.append(X[k])
sum_ = getmin(inside, outside, K)
best = min(best, sum_)
print(best)
ZGVmIGdldG1pbihBLCBCLCBLKToKICAgIEEuc29ydCgpCiAgICBCLnNvcnQocmV2ZXJzZT1UcnVlKQogICAgc3VtXyA9IDAKICAgIGZvciBrIGluIHJhbmdlKEspOgogICAgICAgIGlmIEEgYW5kIEIgYW5kIEFbLTFdPkJbLTFdOgogICAgICAgICAgICBzdW1fICs9IEJbLTFdCiAgICAgICAgICAgIEEucG9wKCkKICAgICAgICAgICAgQi5wb3AoKQogICAgICAgIGVsc2U6CiAgICAgICAgICAgIGJyZWFrCiAgICBzdW1fICs9IHN1bShBKQogICAgcmV0dXJuIHN1bV8KCmZvciB0IGluIHJhbmdlKGludChpbnB1dCgpKSk6CiAgICBOLCBLID0gbWFwKGludCwgaW5wdXQoKS5zcGxpdCgpKQogICAgWCA9IGxpc3QobWFwKGludCwgaW5wdXQoKS5zcGxpdCgpKSkKICAgIGJlc3QgPSAxMCoqOQogICAgZm9yIGkgaW4gcmFuZ2UoTik6CiAgICAgICAgZm9yIGogaW4gcmFuZ2UoaSwgTik6CiAgICAgICAgICAgIGluc2lkZSwgb3V0c2lkZSA9IFtdLCBbXQogICAgICAgICAgICBmb3IgayBpbiByYW5nZShOKToKICAgICAgICAgICAgICAgIGlmIGk8PWsgYW5kIGs8PWo6CiAgICAgICAgICAgICAgICAgICAgaW5zaWRlLmFwcGVuZChYW2tdKQogICAgICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgICAgICBvdXRzaWRlLmFwcGVuZChYW2tdKQogICAgICAgICAgICBzdW1fID0gZ2V0bWluKGluc2lkZSwgb3V0c2lkZSwgSykKICAgICAgICAgICAgYmVzdCA9IG1pbihiZXN0LCBzdW1fKQogICAgcHJpbnQoYmVzdCk=