#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct Node {
    int sum;
    Node (int sum): sum(sum) {}
    Node () {}
};

struct Segment_tree {
    int n;
    vector<Node> t;

    //void insert
};


signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        vector<int> vec(m);
        for (auto &i: vec) cin >> i;
        vector<vector<pair<int, int>>> dp(m, vector<pair<int, int>>(2));
        dp[m - 1][1] = {vec[m - 1], n - 1};
        dp[m - 1][0] = {0, n};
        for (int i = m - 2; i >= 0; i--) {
            int col_chet1 = dp[i + 1][1].second;
            int col_chet2 = dp[i + 1][0].second;
            if (col_chet1 > 0) {
                if (col_chet2 > 0) {
                    if (dp[i + 1][1].first > dp[i + 1][0].first) {
                        dp[i][1] = {dp[i + 1][1].first + vec[i], col_chet1 - 1};
                    } else {
                        dp[i][1] = {dp[i + 1][0].first + vec[i], col_chet2 - 1};
                    }
                } else {
                    dp[i][1] = {dp[i + 1][1].first + vec[i], col_chet1 - 1};
                }
            }
            else if(col_chet2 > 0){
                dp[i][1] = {dp[i + 1][0].first + vec[i], col_chet2-1};
            }
            else {
                dp[i][1] = dp[i + 1][1];
            }
            if (col_chet1 < n) {
                if (col_chet2 < n) {
                    if (dp[i + 1][1].first > dp[i + 1][0].first) {
                        dp[i][0] = {dp[i + 1][1].first - vec[i], col_chet1 + 1};
                    } else {
                        dp[i][0] = {dp[i + 1][0].first - vec[i], col_chet2 + 1};
                    }
                } else {
                    dp[i][0] = {dp[i + 1][1].first - vec[i], col_chet1 + 1};
                }
            }
            else if(col_chet2 > 0){
                dp[i][0] = {dp[i + 1][0].first - vec[i], col_chet2 + 1};
            }
            else {
                dp[i][0] = dp[i + 1][0];
            }
        }
        cout << max(dp[0][1].first, dp[0][0].first) << '\n';
    }

}
