#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<map>

using namespace std;
using ll = long long;


void solve2() {
    ll N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;

    set<ll> qn;
    map<ll, vector<ll>> da;
    map<ll, vector<ll>> db;
    vector<pair<ll, ll>> a(n);

    vector<ll> ap(n + 1);
    vector<ll> bp(n + 1);

    for (int i = 0; i < n; i++) {
        cin >> a[i].second >> a[i].first;
        da[a[i].first].push_back(i);
        qn.insert(a[i].first);
        ap[i + 1] = ap[i] + a[i].second;
    }

    vector<pair<ll, ll>> b(n);
    for (int i = 0; i < m; i++) {
        cin >> b[i].second >> b[i].first;
        db[b[i].first].push_back(i);
        qn.insert(b[i].first);
        bp[i + 1] = bp[i] + b[i].second;
    }

    vector<vector<bool>> dp(n, vector<bool> (m, 0));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (a[i].first == b[j].first) {
                for (auto v : qn) {
                    if (db.find(v) != db.end() && da.find(v) != da.end()) {
                        int pa = upper_bound(da[v].begin(), da[v].end(), i) - da[v].begin();
                        int pb = upper_bound(db[v].begin(), db[v].end(), j) - db[v].begin();
                        if (pa != da[v].size() && pb != db[v].size()) {
                            if (dp[pa][pb] == 0) {
                                dp[i][j] = 1;
                            }
                        }
                    }
                }
                if (dp[i][j] == 0) {
                    if (min(a[i].second, b[j].second) % 2 == 1) {
                        dp[i][j] = 1;
                    }
                }
            }
        }
    }

    while (q--) {
        bool fl = 0;
        int x, y;
        cin >> x >> y;
        int i = upper_bound(ap.begin(), ap.end(), x) - ap.begin() - 1;
        int j = upper_bound(bp.begin(), bp.end(), y) - bp.begin() - 1;
        
        for (auto v : qn) {
            if (db.find(v) != db.end() && da.find(v) != da.end()) {
                int pa = upper_bound(da[v].begin(), da[v].end(), i) - da[v].begin();
                int pb = upper_bound(db[v].begin(), db[v].end(), j) - db[v].begin();
                if (pa != da[v].size() && pb != db[v].size()) {
                    if (dp[pa][pb] == 0) {
                        fl = 1;
                    }
                }
            }
        }
        if (fl == 0) {
            if (min(ap[i + 1] - x, bp[j + 1] - y) % 2 == 1) {
                fl = 1;
            }
        }
        if (fl) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

void solve1() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    for (ll i = 0; i < m; i++) {
        cin >> a[i];
    }
    cout << a[0] * min(m, n - 1) + a[0] * (max(m - n + 1, 0ll) % 2 == 1) << endl;
}


int main() {
    ll t = 1;
    cin >> t;
    while (t--) {
        solve1();
    }
}