#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <tuple>
#include <deque>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int INF = 2 * 1e9;
const ll MAX = 1e15;
const ll MIN = -1e15;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-7;

void solve() {
    int n, m; cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) cin >> x[i];
    int ans = x[0] * min(m, n - 1);
    m -= min(m, n - 1);
    if (m & 1) ans += x[0];
    cout << ans << "\n";
}

signed main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int t = 1;
    cin >> t;
    while (t--) solve();
}
