

#include <bits/stdc++.h>

using namespace std;

const int N = 3e5 + 12;
using ll = long long;
mt19937_64 rng (time (0));
#define int long long
int x[N];
void solve () {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) cin >> x[i];
    if (m <= n) {
        cout << x[1] * m << '\n';
    } else {
        cout << (n - 1) * x[1] + ((m - n) % 2 == 1) * x[1] << '\n';
    }
}
signed main() {
//#ifdef local
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif // local
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int test = 1;
    cin >> test;
    while (test--) solve();
}
