#pragma GCC optimize("O3,unroll-loops")

#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using ull = unsigned long long int;

#define all(x) (x).begin(), (x).end()
#define rall(X) (x).rbegin(), (x).rend()

const ll INF = 2e14;

void solve()
{
    int n, m;
    cin >> n >> m;

    vector<ll> x(m);
    for (int i = 0; i < m; i++)
        cin >> x[i];
    reverse(all(x));

    vector dp(m + 1, vector<ll>(n + 1, -INF));
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
    {
        dp[i][0] = dp[i - 1][1] - x[i - 1];
        dp[i][n] = dp[i - 1][n - 1] + x[i - 1];
        for (int j = 1; j < n; j++)
            dp[i][j] = max(dp[i - 1][j - 1] + x[i - 1], dp[i - 1][j + 1] - x[i - 1]);
    }

    cout << *max_element(all(dp[m])) << '\n';
}

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

    int t;
#ifdef LOCAL
    freopen("C:/work/Day 1/in.txt", "r", stdin);
    freopen("C:/work/Day 1/out.txt", "w", stdout);
    cin >> t;
#else
    cin >> t;
#endif

    while (t--)
        solve();
    return 0;
}
