#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
//#define int ll
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int N = 2e5 + 10;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int &x : a) cin >> x;

    if(m <= n) {
        cout << 1LL * a[0] * m << '\n';
    } else {
        if((m - n) % 2 == 0) cout << 1LL * a[0] * n << '\n';
        else cout << 1LL * a[0] * (n - 1) << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    auto start = clock();
#endif
    int ttt = 1;
    cin >> ttt;
    while(ttt--) {
        solve();
    }
#ifdef LOCAL
    auto end = clock();
    cerr << "TIME: " << (end - start) << "ms" << '\n';
#endif
}