#include <bits/stdc++.h>
using namespace std;
//using long long = long long;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n,m;
        cin >> n >> m;
        vector<long long> b(m + 1);
        for(int i = 1;i <= m;i++){
            cin >> b[i];
        }
        //cout << "ohagf";
        vector<vector<long long>> dp(n + 1,vector<long long> (m + 1,-1e12));
        if(n % 2 == m % 2){
            dp[n][0] = 0;
        }else{
            dp[n-1][0] = 0;
        }

        //cout << "a";
        for(int i = 1;i <= m;i++){
            //cout << "b'";
            for(int j = 1;j < n;j++){
                dp[j][i] = max(dp[j + 1][i - 1] + b[i],dp[j-1][i-1] - b[i]);
            }
            dp[0][i] = dp[1][i-1] + b[i];
            dp[n][i] = dp[n-1][i-1] - b[i];
        }
        long long ma = 0;
        for(int j = 0;j <= n;j++){
            ma = max(ma,dp[j][m]);
        }
        cout << ma << endl;
    }
}
