#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll mod = 1e9+7;

ll bpow(ll a, ll n) {
    ll res = 1;
    while (n) {
        res *= a;
        if (n & 1) a *= a;
        n /= 2;
    }
    return res;
}

const int N = 5e5+52;
const int M = 2e3+52;

ll a[N];

void altay() {
    int n, m;
    cin >> n >> m;
    map<ll, ll> dp[m+2];

    dp[0][0] = 0;
    for (int i = 1; i <= m; i++) {
        ll b;
        cin >> b;
        for (auto it : dp[i-1]) {
            dp[i][b-it.fi] = it.se;
            if (dp[i].find(it.fi) == dp[i].end()) {
                dp[i][it.fi] = b-it.se;
            }
            else dp[i][it.fi] = max(b-it.se,dp[i][it.fi]);
        }
    }

    ll ans = -1e18;
    for (auto it : dp[m]) {
        ans = max(ans, it.fi + it.se);
    }

    cout << ans << "\n";
 }

int main() {

    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        altay();
    }

    return 0;
}
