#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll INF = 1e14;
ll MOD = 1e9 + 7;

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for(auto &i : x) cin >> i;
    ll res = 0;
    for(ll mask = 0;mask < (1 << m);mask++) {
        if(mask != 0 && n == 1) break;
        vector<ll> f, s;
        for(ll i = 0;i < m;i++) {
            if((mask >> i) & 1) {
                f.push_back(x[i]);
            }
            else {
                s.push_back(x[i]);
            }
        }
        reverse(f.begin(), f.end());
        reverse(s.begin(), s.end());
        ll fs = 0;
        ll t = 1;
        for(ll i = 0;i < f.size() && f.size();i++) {
            fs += f[i] * t;
            t *= -1;
        }
        ll ss = 0;
        t = 1;
        for(ll i = 0;i < s.size() && s.size();i++) {
            ss += s[i] * t;
            t *= -1;
        }
        res = max(res, fs + ss);
    }
    cout << res;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    ll tt = 1;
    cin >> tt;
    while(tt--) {
        solve();
        cout << '\n';
    }
    return 0;
}
