#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <climits>
#include <cmath>
#include <iomanip>

#pragma GCC optimize("O3,unroll-loops")

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;

#define all(v) v.begin(), v.end()
#define len(v) (ll)v.size()

mt19937 rnd(525252);

const ll INF = 1e9, SZ = 5e3, MOD = 1e9 + 7;
const ld eps = 1e-8, pi = acosl(-1);


void solve() {
    ll n, m; cin >> n >> m;
    vector<ll>x(m, 0);
    for (auto &i : x) cin >> i;
    if (n == 1){
        ll cur = 0;
        for (ll i = m - 1; i >= 0; --i){
            if ((m - i) % 2) cur += x[i];
            else cur -= x[i];
        }
        cout << cur;
        return;
    }
    ll best = -INF;
    for (ll mask = 0; mask < (1 << m); ++mask){
        ll cur = 0;
        ll l1 = 1, l0 = 1;
        for (ll i = m - 1; i >= 0; --i){
            if ((mask >> i) & 1){
                cur += l1 * x[i];
                l1 *= -1;
            }
            else{
                cur += l0 * x[i];
                l0 *= -1;
            }
        }
        best = max(best, cur);
    }
    cout << best;
}

int main()
{
	ll t = 1;
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
    cin >> t;

	while (t--) {
		solve();
		cout << '\n';
	}
}
