#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
void getint(int &x)
{
    int ch = x = 0;
    while (!isdigit(ch = getchar()))
        ;
    for (; isdigit(ch); ch = getchar())
        x = x * 10 + ch - '0';
}
const int N = 1e5 + 10;
int a[N];
int main()
{
    int T, n, m;
    getint(T);
    while (T--)
    {
        getint(n), getint(m);
        for (int i = 0; i < n; i++)
            getint(a[i]);
        sort(a, a + n);
        long long ans = 0;
        for (int i = 0; i < m; i++)
            ans += a[i] * a[2 * m - i - 1];
        printf("%lld\n", ans);
    }
    return 0;
}