#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <experimental/random>

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O3,unroll-loops")
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using str = string;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const ll INF = 1e18, MOD = 1e9 + 7;
#define int long long

void solve();

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
        cout << "\n";
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int l = (m + 1) / 2;
    int r = n - 1 + (m - (n - 1) + 1) / 2;
    r = min(r, m);
    l = r;
    int ans = -INF;
    for (int k = l; k <= r; ++k) {
        int sum = 0;
        for (int i = 0; i < m - k; ++i) {
            sum += -1ll * a[i];
        }
        for (int i = m - k; i < m; ++i) {
            sum += a[i];
        }
        ans = max(ans, sum);
    }
    cout << ans;
}
