#include <iostream>
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define st first
#define nd second

/**
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
**/

int a[300'300];
int p[300'300];

void solve()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        cin >> a[i];
    }
    sort(a, a + m);
    p[0] = 0;
    for (int i = 1; i <= m; ++i)
    {
        p[i] = p[i - 1] + a[i - 1];
    }
    int ans = -998244353LL * 998244353;

    for (int i = 0; 2 * i < n; ++i)
    {
        int z = 0;
        z += p[i] - p[0];
        z -= p[n - 1] - p[n - 1 - i];
        z += p[n - 1 - i] - p[i];
        ans = max(ans, z);
    }
    cout << ans << '\n';
}

signed main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; ++i)
    {
        solve();
    }
    return 0;
}
