#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define vi vector<ll>
#define vii vector<vi>
#define vip vector<pair<ll, ll>>
#define viip vector<vip>
#define endl '\n'
#define pb push_back
#define all(a) a.begin(), a.end()

ll INF = 1e9;

void solve() {
    ll n, m;
    cin >> n >> m;
    vi a(n);
    vi x(m);
    for (ll i = 0; i < m; i++) {
        cin >> x[i];
    }
    vector<pair<ll, ll>> dp;
    dp.pb({0, 0});
    for (ll i = 0; i < m; i++) {
        vector<pair<ll, ll>> ndp;
        for (auto [c, d]: dp) {
            ll cc = x[i] - c;
            ll dd = d;
            if (cc > dd)
                swap(cc, dd);
            ndp.pb({cc, dd});
            cc = c;
            dd = x[i] - d;
            if (cc > dd)
                swap(cc, dd);
            ndp.pb({cc, dd});
        }
        sort(all(ndp));
        ndp.resize(unique(all(ndp)) - ndp.begin());
        swap(dp, ndp);
    }
    ll ans = -INF;
    for (auto [i, j]: dp)
        ans = max(ans, i + j);
    cout << ans << endl;
}

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