#include <bits/stdc++.h>
#define int long long

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    cin >> t;
    int inf = LONG_LONG_MIN;
    for(int p = 0; p < t; ++p){
        int n, m;
        cin >> n >> m;
        vector<vector<int>> dp(m, vector<int> (n + 1, inf));

        vector<int> a(m);
        for(int i = m - 1; i >= 0; --i)
            cin >> a[i];

        dp[0][1] = a[0];
        for(int i = 1; i < m; ++i){
            for(int j = 0; j < n + 1; ++j){
                if(j - 1 >= 0 && dp[i - 1][j - 1] != inf)
                    dp[i][j] = dp[i - 1][j - 1] + a[i];
                if(j + 1 <= n && dp[i - 1][j + 1] != inf)
                    dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] - a[i]);
            }
        }

        int maxim = inf;
        for(int j = 0; j < n + 1; ++j)
            maxim = max(maxim, dp[m - 1][j]);
        cout << maxim << endl;
    }
}
