#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

auto seed = chrono::high_resolution_clock().now().time_since_epoch().count();
mt19937 rnd(seed);

template<typename T>
using orderet_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename V>
using table = gp_hash_table<T, V>;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ld = long double;
using dd = double;

#define int ll

void solve(){
    int n, m;
    cin>>n>>m;
    vector<pair<int, int>> v1 = {{0, 0}};
    for(int i = 0; i < m; ++i){
        if(v1.size() >= 2000) exit(-1);
        int x;
        cin>>x;
        vector<pair<int, int>> v;
        for(auto [a, b]: v1){
            v.push_back({x-a, b});
            v.push_back({a, x-b});
        }
        sort(v.begin(), v.end());
        v1 = {};
        int k = v.size();
        v.push_back({1e18, 1e18});
        for(int i = 0; i <= k; ++i){
            if(i == 0 || v[i-1].first != v[i].first){
                if(i > 0) v.push_back(v[i-1]);
                if(i < k) v1.push_back(v[i]);
            }
        }
    }
    int ans = -2e18;
    for(auto c: v1) ans = max(ans, c.first + c.second);
    cout << ans << "\n";
}

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