#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#define all(x) begin(x), end(x)
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

void solve(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    for (auto &x: a) cin >> x;
    if (n == 1){
        ll ans = 0;
        for (ll i=0; i<m; ++i) ans = a[i] - ans;
        cout << ans;
    }
    if (n == 2){
        ll ma = LLONG_MIN;
        for (ll i=0; i<(1 << m); ++i){
            ll a1 = 0, a2 = 0;
            for (ll j=0; j<m; ++j) (((i >> j) & 1) ? a2 = a[j] - a2 : a1 = a[j] - a1);
            ma = max(ma, a1 + a2);
        }
        cout << ma;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t=1;
    cin >> t;
    while (t--) solve(), cout << '\n';
    return 0;
}
