#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const ll inf = 2e18;

struct node {
    ll sm, mx = -inf, mn = inf;
    vector<ll> a;
};

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), x(m);
    for (int i = 0; i < m; ++i) cin >> x[i];
    ll ans = -1e18;
    if (n >= m) cout << x[0] * n << '\n';
    else cout << x[0] * (n - 1) + ((m - n + 1) % 2) * x[0] << '\n';
    return;
    vector<vector<ll>> dp(2, vector<ll>(m + 1, -inf));
    dp[0][0] = 0;
    dp[1][0] = 0;
    vector<ll> a0 = a, a1 = a;
    auto sum = [&](const vector<ll> &vec) {
        ll s = 0;
        for (const auto &item: vec) s += item;
        return s;
    };
    auto minx = [&](vector<ll> vec, ll d) {
        vec[0] = d - vec[0];
        return vec;
    };
    auto maxx = [&](vector<ll> vec, ll d) {
        vec[1] = d - vec[1];
        return vec;
    };
    vector<vector<ll>> nado(m + 1, vector<ll>(2));
    for (int i = 1; i <= m; ++i) {
        a = minx(a, x[i - 1]);
        dp[0][i] = sum(a);
    }
    for (int i = 1; i <= m; ++i) {
        for (int j = 0; j < i; ++j) {
            auto tmp = nado[j];
            for (int k = j + 1; k < i; ++k) {
                tmp = minx(tmp, x[k - 1]);
            }
            tmp = maxx(tmp, x[i - 1]);
            if (sum(tmp) > dp[1][i]) {
                dp[1][i] = sum(tmp);
                nado[i] = tmp;
            }
        }
    }
    cout << max(dp[0][n], dp[1][n]) << '\n';
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) solve();
}
