#include<bits/stdc++.h>

using namespace std;
#define int long long

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) cin >> x[i];
    vector<map<int, int>> dp(m);
    dp[0][0] = dp[0][x[0]] = x[0];
    int inf = 400 * 400;
    for (int i = 1; i < m; ++i) {
        for (int j = -inf; j < inf; ++j) {
            if (dp[i - 1].find( x[i] - j) != dp[i - 1].end()) {
                dp[i][j] = dp[i - 1][ x[i] - j] - (x[i] - j) + j;
            }
            if (dp[i - 1].find(j) != dp[i - 1].end()) {
                dp[i][j] = x[i] - dp[i-1][j] + j + j;
            }
        }
    }
    int ans = -inf;
    for (int j = -inf; j < inf; ++j) {
        if (dp.back().find(j) != dp.back().end())
            ans = max(ans, dp.back()[j]);
    }
    cout << ans << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
