#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define sll __int128
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int long long

mt19937 rnd(time(0));

ll INF = 1e18;

void dfs(int v, int w, vector<vector<int>> &g, vector<int> &s){
    for (auto to : g[v]){
        dfs(to, min(w, s[v]), g, s);
    }
    s[v] = min(s[v], w);
}

int mx = 0, sm = 1;

void dfs2(int v, vector<vector<int>> &g, vector<int> &s, vector<int> &ch, vector<int> &ans){
    vector<pair<int, int>> a;
    for (auto to : g[v]){
        a.push_back({-s[to], to});
    }
    sort(all(a));
    for (auto [w, to] : a){
        ans[to] = sm - mx; sm++;
        dfs2(to, g, s, ch, ans);
        ch[v] += ch[to];
    }
    mx = max(mx, ch[v]);
}

void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> b(m);
    for (int i = 0; i < m; i++){
        cin >> b[i];
    }
    vector<pair<int, int>> a = {{0, 0}};
    for (int i = 0; i < m; i++){
        set<pair<int, int>> st;
        for (auto [x, y] : a){
            st.insert({b[i] - x, y});
            st.insert({x, b[i] - y});
        }
        a.clear();
        for (auto el : st){
            a.push_back(el);
        }
    }
    ll ans = -INF;
    for (auto [x, y] : a){
        ans = max(ans, x + y);
    }
    cout << ans << "\n";
}

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