#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define pii pair<int, int>
#define f first
#define s second
#define ld long double

using namespace std;
using namespace __gnu_pbds;
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rnd(time(0));
const int INF = 1e18;

struct VEC
{
    int x, y;
};

VEC operator +(VEC a, VEC b)
{
    return {a.x+b.x, a.y+b.y};
}
VEC operator -(VEC a, VEC b)
{
    return {a.x-b.x, a.y-b.y};
}
int operator *(VEC a, VEC b)
{
    return a.x*b.x + a.y*b.y;
}
int operator ^(VEC a, VEC b)
{
    return a.x*b.y - a.y*b.x;
}

void solve()
{
    int n, m; cin >> n >> m;
    int x[m];
    for(int i=0; i<m; ++i) cin >> x[i];
    reverse(x, x+m);
    int dp[m+1][n][2];
    for(int i=0; i<n; ++i)
    {
        dp[0][i][0] = 0;
        dp[0][i][1] = -INF;
    }
    for(int i = 1; i<=m; ++i)
    {
        dp[i][0][0] = max(dp[i-1][0][1], dp[i-1][1][i%2]) - x[i-1];
        dp[i][0][1] = max(dp[i-1][0][0], dp[i-1][1][(i-1)%2]) + x[i-1];
        dp[i][1][0] = max(dp[i-1][1][1], dp[i-1][0][i%2]) - x[i-1];
        dp[i][1][1] = max(dp[i-1][1][0], dp[i-1][0][(i-1)%2]) + x[i-1];
    }
    int ans = -INF;
    for(int i = 0; i<n; ++i)
    {
        ans = max(ans, dp[m][i][0]);
        ans = max(ans, dp[m][i][1]);
    }
    cout << ans << "\n";
    return;
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t;
    //freopen("in.txt", "r", stdin); int t; cin >> t;
    //freopen("out.txt", "w", stdout);
    while(t--)
        solve();
    return 0;
}

/*

for(int j = 0; j<n; ++j)
        {
            dp[i][j][0] = max(dp[i-1][j][1], dp[i-1][1-j][(i-2)%2]);
            dp[i][j][1] = -INF;

            //if(dp[i-1][j][1]!=-INF)
            //    dp[i][j][0] = dp[i-1][j][1] - x[i-1];
            //if(dp[i-1][j][0]!=-INF)
            //    dp[i][j][1] = dp[i-1][j][0] + x[i-1];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 int s = 0;
            for(int k = i-1; k>=0; --k)
            {
                if(dp[k][j][0]!=-INF)
                {
                    int cur = dp[k][j][0] + x[i-1];
                    if(k%2==1) cur += s;
                    else cur -= s;
                    dp[i][j][1] = max(dp[i][j][1], cur);
                }
                if(dp[k][j][1]!=-INF)
                {
                    int cur = dp[k][j][1] - x[i-1];
                    if((k-1)%2==1) cur += s;
                    else cur -= s;
                    dp[i][j][0] = max(dp[i][j][0], cur);
                }
                if(k!=0 && (i - k)%2==1)
                    s += x[k-1];
                else if(k!=0 && (i - k)%2==0)
                    s -= x[k-1];
            }
        }
*/
