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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;

#define all(a) a.begin(), a.end()

using ordered_set = tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

void solve();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef _GLIBCXX_DEBUG
    freopen("input", "r", stdin);
#endif
    ll t = 1;
    cin >> t;
    while (t--)
        solve();
}

const ll INF = 1e18;

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for (ll &i: x)
        cin >> i;
    reverse(all(x));
    vector<vector<ll>> dp(m + 1, vector<ll>(n + 1, -INF));
    dp[0][0] = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 1; j <= n; j++)
            dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] - x[i]);
        for (int j = 0; j < n; j++)
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + x[i]);
    }
    cout << *max_element(all(dp[m])) << '\n';
}