#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define yes() cout << "YES\n"
#define no() cout << "NO\n"
using ll = long long;
using ld = long double;
using namespace std;
using namespace __gnu_pbds;

template<typename K>
using oset = tree<K, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

struct segTree {
    vector<int> t;
    int n;

    void build(int v, int l, int r, vector<int>& a) {
        if (r - l == 1) {
            t[v] = a[l];
            return;
        }

        int m = (l + r) / 2;

        build(2 * v, l, m, a);
        build(2 * v + 1, m, r, a);

        t[v] = t[2 * v] + t[2 * v + 1];
    }

    segTree(vector<int>& a) {
        n = a.size();
        t.resize(4 * n);

        build(1, 0, n, a);
    }

    int get(int v, int l, int r, int ql, int qr) {
        if (l >= qr || r <= ql) {
            return 0;
        }

        if (ql <= l && r <= qr) {
            return t[v];
        }

        int m = (l + r) / 2;

        return get(2 * v, l, m, ql, qr) + get(2 * v + 1, m, r, ql, qr);
    }

    int get(int ql, int qr) {
        return get(1, 0, n, ql, qr);
    }

    void upd(int v, int l, int r, int idx, int val) {
        if (r - l == 1) {
            t[v] = val;
            return;
        }

        int m = (l + r) / 2;

        if (idx < m) {
            upd(2 * v, l, m, idx, val);
        } else {
            upd(2 * v + 1, m, r, idx, val);
        }

        t[v] = t[2 * v] + t[2 * v + 1];
    }

    void upd(int idx, int val) {
        upd(1, 0, n, idx, val);
    }
};

void solve() {
    int n, m;
    cin >> n >> m;

    set<int> st;

    vector<int> b(m);
    for (int& i : b) {
        cin >> i;
        st.insert(i);
    }

    int x = *st.begin();

    if (st.size() == 1 && x >= 0) {
        if (m >= n) {
            cout << n * x  << "\n";
        } else {
            if (n % 2 == m % 2) {
                cout << n * x << "\n";
            } else {
                cout << (n - 1) * x << "\n";
            }
        }
        return;
    }

    int ans = 0;

    for (int mask = 0; mask < (1 << m); mask++) {
        int a0 = 0;
        int a1 = 0;

        for (int i = 0; i < m; i++) {
            if (mask >> i & 1) {
                a1 = b[i] - a1;
            } else {
                a0 = b[i] - a0;
            }
        }

        ans = max(ans, a0 + a1);
    }

    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
}