#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;
using oset = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
const ll nMax = 2100;
ll dp[nMax][nMax];

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    memset(dp, 0xf0, sizeof dp);
    for (int i = 0; i <= n; i++)dp[0][i] = 0;
    for (auto &o: x) cin >> o;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j <= n; j++) {
            if (j)
                dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + x[i]);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] - x[i]);
        }
    }
    cout << dp[m][0] << '\n';
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0)->sync_with_stdio(0);
    int tt;
    cin >> tt;
    while (tt--)solve();
}