#include <bits/stdc++.h>
#define ll long long
using namespace std;
void solve() {
    //cin.tie(nullptr);
    //ios::sync_with_stdio(0);
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    ll sum = 0;
    for (int i = 0;i < m;i++) {
        cin >> a[i];
        sum+=a[i];
    }
    reverse(a.begin(),a.end());
    vector<vector<ll>> dp(m+1,vector<ll> (2,-1e18));
    dp[0][0] = 0;
    if (n>=m) {
        cout << sum << '\n';
        return;
    }
    dp[n][1] = 0;
    for (int i = 0;i < n;i++) {
        dp[n][1]+=a[i];
    }
    for (int i = n+1;i < m+1;i++) {
        for (int j = 0;j <= 1;j++) {
            if (j!=0) {
                dp[i][j] = max(dp[i][j],dp[i-1][j-1]+a[i-1]);
            }
            if (j!=1) {
                dp[i][j] = max(dp[i][j],dp[i-1][j+1]-a[i-1]);
            }
            if (dp[i][j]>-1e17) {
                //cout << dp[i][j] << ' ';
            }
            else {
                //cout << 0 < < ' ';
            }
        }
        //cout << '\n';
    }
    ll ma = -1e18;
    for (int j = 0;j <= 1;j++) {
        ma = max(ma,dp[m][j]);
    }
    cout << ma << '\n';
}
int main()
{
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
